Ask questionsBug: MobX-like observer pattern doesn't work with Fast Refresh because Hooks don't get detected

<!-- Please provide a clear and concise description of what the bug is. Include screenshots if needed. Please test using the latest version of the relevant React packages to make sure your issue has not already been fixed. -->

React version: 17.0.0

Steps To Reproduce

  2. Delete one of the hooks there

<!-- Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Issues without reproduction steps or code examples may be immediately closed as not actionable. -->

Link to code example:

<!-- Please provide a CodeSandbox (, a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: -->

The current behavior

You get "Rendered more hooks than during the previous render" error

The expected behavior

Should hot reload and re-mount the component.

The source of the issue have two parts:

  1. react-refresh and the bundler fails to inject signature to the component
  2. When no signature apparent, react-refresh consider the components as compatible, which is not always true, as in the repro

I've filed an issue also for the webpack plugin: Mobx related issue:


Answer questions Jack-Works

If anyone using react-refresh-typescript (instead of react-refresh/babel) and having this problem, please cc me. Thanks!

Github User Rank List