Skip to content Skip to sidebar Skip to footer

Webpack External React Causes React Hooks Error

I am the author of FireJS. I am encountering an issue with react hooks. (node:21793) UnhandledPromiseRejectionWarning: Error: Invalid hook call. Hooks can only be called inside of

Solution 1:

I figured out how to fix this issue. You need to bundle react, react-dom and react-dom/server to the same bundle.

Eg:

window.React = require("react");
window.ReactDOM = require("react-dom")
window.ReactDOMServer = require("react-dom/server")

Bundle the above file and import it as your first script.

Post a Comment for "Webpack External React Causes React Hooks Error"