Skip to content

How to react on props change #3715

Answered by urugator
fellmann asked this question in Q&A
Discussion options

You must be logged in to vote

https://mobx.js.org/react-integration.html#computed-props

Either use effect to move props to local observables and another effect with reaction accessing only observables.
Or unwrap observables to immutable primitives and pass them as deps to normal useEffect without reaction.
Or don't do it reactively and move the effect to an action that caused the props to update.

I remember props were automatically transformed to observables.

This was only possible with classes and we're actually about to remove this feature.

This makes combining props and locally stored observables in reactions much more complicated.

Yes, ideally try to avoid that.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by fellmann
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants