React-hot-loader: react-🔥-dom patch is not detected

半世苍凉 提交于 2019-12-31 11:10:19

问题


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

React-hot-loader: react-🔥-dom patch is not detected. React 16.6+ features may not work.

However, when I look into the source code, there is a comment:

// Actually everything works...

What does this warning actually mean? Is this something I should fix or just let it be?


回答1:


Per my comment above, it's looking like react-hot-loader wants the @hot-loader/react-dom package instead of standard react-dom:

  • https://github.com/gaearon/react-hot-loader#react--dom
  • https://github.com/hot-loader/react-dom

Personally I'm a little concerned with swapping that out though since react-dom is a core part of any react-based application. Also it seems based on some of the linked issues and code comments that maybe this is just a short-term workaround to support new react features like hooks.

So I guess there's two options:

  • Wait a little longer to see if they drop that requirement (and maybe run into a few edge cases for hot loading).
  • Follow the instructions to get rid of the warning.

Update

You can disable the warning like so:

import { hot, setConfig } from 'react-hot-loader'

setConfig({
    showReactDomPatchNotification: false
})



回答2:


So this appears to be an artifact of the development process. Looks like there was some back-and-forth on what to do in this case. The error message was commented out, and then later added back as a fix for an issue: https://github.com/gaearon/react-hot-loader/commit/efc3d6b5a58df77f6e0d5ca21bef54e8f8732070.

So, it looks like it's a minor warning, and you may be just fine unless you need specific features.

It might be a good idea to ask for clarity on this from the maintainers, since they seem slightly confused themselves :)




回答3:


In short - React-Hot-Loader is something that "might not work". It has a lot of problems and limitations.

"hot-patch" was created to (first) support new React features, and (second) make it more stable.

  • Without this patch - something really might not work.
  • With the patch - something might work better, especially in the future.

It's the only our(ok, mine) hope to mitigate the major problems RHL has, and tracked as "version 5" - https://github.com/gaearon/react-hot-loader/milestone/3

hot-loader/react-dom is not a "third party" lib - it's the same react-dom with some patches applied to dev mode only (you might check build scripts).

It just moves some dark magic, RHL uses to work, inside react, and actually removes it. RHL == black magic. RHL + patch == twice less magic.



来源:https://stackoverflow.com/questions/54770535/react-hot-loader-react-dom-patch-is-not-detected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!