mobx: An exception is thrown when using Mobx6 and react18 in development mode

Intended outcome:

When I use React18’s new rendering API ReactDOM.createRoot().render, I get a lot of warnings. It should be guaranteed to be consistent with the previous behavior, run normally, and not throw warnings

warning message: react_devtools_backend.js:3973 Warning: Can’t perform a React state update on a component that hasn’t mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.

Actual outcome:

I get a lot of warnings, but can’t find the information I have in it, like below

Versions

mobx@^6.6.1 mobx-react@^7.5.1

Dzdw92s8dG

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Please create a runnable reproduction using codesandbox. Here is an example of Mobx + React 18 that shows no warnings: https://codesandbox.io/s/vigilant-hellman-3mjsty?file=/index.js

@kubk hello, this is the demo code link. https://codesandbox.io/s/mobx6-and-react18-2rx40e?file=/index.js