React-hot-loader: react-

后端 未结 6 509
长发绾君心
长发绾君心 2021-02-01 13:14

I updated some npm packages in my Gatsby project and now I\'m seeing this warning in console:

React-hot-loader: react-

6条回答
  •  逝去的感伤
    2021-02-01 13:28

    Update 2020

    As of summer 2020, this is the current solution recommended on Gatsby's GitHub repository:

    Step 1

    Run this command - But running this alone won't fix the issue:

    npm install -D @hot-loader/react-dom
    // or
    yarn add -D @hot-loader/react-dom
    

    Step 2

    Modify gatsby-node.js to add the following:

    exports.onCreateWebpackConfig = ({ stage, actions }) => {
      if (stage.startsWith("develop")) {
        actions.setWebpackConfig({
          resolve: {
            alias: {
              "react-dom": "@hot-loader/react-dom",
            },
          },
        })
      }
    }
    

    Restart gatsby develop. The warning is gone.

提交回复
热议问题