question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

What is hook.js and what is its benefits?

See original GitHub issue

Just like I said, I read several starters and studied many implementations. I cannot understand what does the hooks.js do?

I had no problem until installing tailwindcss. By the docs guides, I add the require('tailwindcss'), to the postcss.config.js file and got this error:

/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/node_modules/postcss/lib/lazy-result.es6:319
                throw new Error(
                      ^
Error: Use process(css).then(cb) to work with async plugins
    at LazyResult.sync (/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/node_modules/postcss/lib/lazy-result.es6:319:23)
    at LazyResult.warnings (/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/node_modules/postcss/lib/lazy-result.es6:157:21)
    at fetch (/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/lib/index.js:102:16)
    at hook (/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/lib/index.js:125:18)
    at Object.cssModulesHook [as .css] (/home/amerllica/WebstormProjects/heja/node_modules/css-modules-require-hook/lib/attachHook.js:16:20)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/home/amerllica/WebstormProjects/heja/src/app/index.tsx:10:1)
[nodemon] app crashed - waiting for file changes before starting...

Then I look for the css-modules-require-hook and I see a bad thing 🤦‍♂️ My GOD. this library is for 2 years ago.

Here are a few questions:

  1. what is hooks.js?
  2. what does hooks.js do?
  3. why reading the postcss configuration is not in the Webpack config?
  4. what does css-modules-require-hook do?
  5. what does asset-require-hook do?
  6. is it possible to omit the hooks.js and add its configurations into Webpack config?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
wellyshencommented, Jun 15, 2020

@theogravity

For tailwind, as my experience it’s easy to be integrated with this starter by following its documentation (see this issue). If you have any problem, please let me know, I’m glad to help you.

For isopmorphic-style-loader, I think we’re on the same page.

2reactions
wellyshencommented, May 25, 2020

@amerllica The isomorphic-style-loader can be one of the option. However I will find a way to eliminate the hook.js after migrating webpack to v6. Let’s keep this issue for enhancement.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Introducing Hooks - React
With Hooks, you can extract stateful logic from a component so it can be tested independently and reused. Hooks allow you to reuse...
Read more >
React Hooks and its Advantages - Board Infinity
React Hooks are a type of function that allows the users to hook into react state and life-cycle features from function components. React ......
Read more >
Custom React JS Hooks: What Are They and When to Use ...
Custom React JS hooks offer three major benefits over standard library hooks: Reusability, readability, and testability. Reusability. Custom ...
Read more >
React Hooks and its Advantages - DEV Community ‍ ‍
Advantages of react hooks over class component : The main advantage of react hooks is the re-usability of stateful logic. It can be...
Read more >
React Hooks — advantages and comparison to older reusable ...
hooks are easier to work with and to test (as separated functions from React components*) and make the code look cleaner, easier to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found