Issue with webpack config for configuring react as externals
-
I am utilizing
react-image-gallery
for creating image gallery, but I am getting
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons: 1. You might have mismatching versions of React and the renderer (such as React DOM) 2. You might be breaking the Rules of Hooks 3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
Upon looking online I found that I need to declare react and react-dom as externals and tried writing webpack.config.js
const webpack = require("webpack"); const path = require("path"); module.exports = { entry: "./src/index.js", output: { path: path.resolve(__dirname, "build"), filename: "drstk.build.js", libraryTarget: "window", }, externals: { react: "React", "react-dom": "ReactDOM", }, };
for react and scss files it is showing I need to utilize appropriate loaders. I dont know what to do here and am struck with it, I dont want to change the build style of wp-script
- The topic ‘Issue with webpack config for configuring react as externals’ is closed to new replies.