在Gatsby开发中,出现此错误。
React-Hot-Loader: react--dom patch is not detected. React 16.6+ features may not
work.
似乎是一个永无止境的错误,但是有没有办法从控制台中将其删除?
答案 0 :(得分:1)
哦,天哪……issue中有一个解决方法
TL; DR
npm install -D @hot-loader/react-dom
在gatsby-node.js
中添加以下内容:
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'
}
}
}
答案 1 :(得分:1)
如here所述,最好使用actions.setWebpackConfig
,因为它会自动与默认配置合并:
exports.onCreateWebpackConfig = ({ stage, actions }) => {
if (stage.startsWith("develop")) {
actions.setWebpackConfig({
resolve: {
alias: {
"react-dom": "@hot-loader/react-dom",
},
},
})
}
}