Reactjs 反应-🔥-未检测到dom修补程序。反应16.6+;功能可能不起作用

Reactjs 反应-🔥-未检测到dom修补程序。反应16.6+;功能可能不起作用,reactjs,gatsby,Reactjs,Gatsby,在盖茨比开发中,我得到了这个错误 React-Hot-Loader: react-Oh man... There's a workaround in this issue TL;DR npm install -D @hot-loader/react-dom In gatsby-node.js add the following: exports.onCreateWebpackConfig = ({ getConfig, stage }) => { const config =

在盖茨比开发中,我得到了这个错误

React-Hot-Loader: react-Oh man... There's a workaround in this issue

TL;DR

npm install -D @hot-loader/react-dom

In
gatsby-node.js
add the following:

exports.onCreateWebpackConfig = ({ getConfig, stage }) => {
  const config = getConfig()
  if (stage.startsWith('develop') && config.resolve) {
    config.resolve.alias = {
      ...config.resolve.alias,
      'react-dom': '@hot-loader/react-dom'
    }
  }
}

React热加载程序:React-噢,伙计。。。这是一个解决办法

TL;博士

npm安装-D@hot loader/react dom

gatsby node.js
中添加以下内容:

exports.onCreateWebpackConfig = ({ stage, actions }) => {
  if (stage.startsWith("develop")) {
    actions.setWebpackConfig({
      resolve: {
        alias: {
          "react-dom": "@hot-loader/react-dom",
        },
      },
    })
  }
}
如前所述,最好使用
actions.setWebpackConfig
,因为它会自动与默认配置合并: