How to Prevent Multiple Copies Of React from Loading?

To prevent multiple copies Of React from loading, we put the path of React into our Webpack config.

For instance, we write

module.exportrs = {
  resolve: {
    alias: {
      react: path.resolve("node_modules/react"),
    },
  },
};

in webpack.config.js to set the alias for react to path.resolve("node_modules/react").

Then when react is imported, it’s imported from the path returned from path.resolve("node_modules/react")