Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange error with React Devtools: the creation of the observable instance must be done on the initializing phase #1303

Open
2 tasks done
danielkcz opened this issue May 30, 2019 · 5 comments
Labels
bug Confirmed bug help/PR welcome Help/Pull request from contributors to fix the issue is welcome

Comments

@danielkcz
Copy link
Contributor

Bug report

  • I've checked documentation and searched for existing issues
  • I've made sure my project is based on the latest MST version

Sandbox link or minimal reproduction code
I am not able to reproduce it anywhere else unfortunately

Describe the expected behavior

MST shouldn't be surprised by shenanigans of React devtools :)

Describe the observed behavior

MST: 3.14.0
MobX: 5.9.4
React Devtools: 3.6.0

image

You can see the backend.js in stacktrace which is from React devtools, not my application code. It happens somewhat randomly when devtools are active and I reload the page.

I am fairly certain this wasn't happening before, so it's most likely some change in React Devtools which started doing something shady.

@xaviergonz
Copy link
Contributor

Yeah, react dev tools do very weird stuff to passed props. It used to access them and all its props when they were no longer part of the props of a component (therefore triggering warnings/errors about detached objects being accessed).
I wonder if there's a way to detect when react-dev-tools are doing their weird "deep reading" and do something else instead (like returning the snapshot or whatever)...

@xaviergonz xaviergonz added bug Confirmed bug help/PR welcome Help/Pull request from contributors to fix the issue is welcome labels Jun 1, 2019
@barbalex
Copy link

barbalex commented Mar 11, 2020

I got this error in my app after refacturing when moving from using auth0 to firebase.
I have no idea why. backend.js was not in the stack trace.

I found out that the issue did not occur if I deactivated mst-persist (which has worked flawlessly for two years so far). So I ended up doing that 😢

My app is way to complicated to build a simple reproducible example so I am afraid this will not be any help to solve issues.

@kresli
Copy link

kresli commented Jun 2, 2020

for me this happened because onClick the button removed value from map and button's parent tried to assign the value to react state which was already deleted.

const [element, setElement] = useState();
<div onClick={() => setElement(element)}>
  <div onClick={() => store.delete(element)}/>
</div>

@danielkcz
Copy link
Contributor Author

@kresli That's actually correct behavior I think. The issue I posted above is false negative due to React Devtools shenanigans.

@quanlh-ttlab
Copy link

quanlh-ttlab commented Oct 25, 2022

I got this error in my react native app when try to update data mapping for component in react-native-reanimated ui lib. I dont know why but when i remove dependencies in hook function where mst action place at, it worked.
Also this error is appear when using replace an array state and when i use detach and applySnapshot instead, the error is disappear

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug help/PR welcome Help/Pull request from contributors to fix the issue is welcome
Projects
None yet
Development

No branches or pull requests

5 participants