Load React JS component from external script in “run time”

后端 未结 2 2025
走了就别回头了
走了就别回头了 2021-01-06 00:06

I\'m using React JS + webpack. General case that I need to resolve is to dynamically load React components that were not bundled with main application. Kind of pluggable com

2条回答
  •  难免孤独
    2021-01-06 00:13

    It sounds like you are asking how to externalize React. If so, you can list libraries as "externals" in your webpack.config.js file:

    webpackConfig.externals = {
      "react": "React",
      "react-dom": "ReactDOM",
      ...
    }
    

提交回复
热议问题