Closed ifokeev closed 8 years ago
@ifokeev I'm actually unsure about this and don't have much experience with it, but if you can find more information or the root cause I can definitely work on fixing it.
@AriaFallah as I understand all properties in your mobxstore are observable. So maybe it's a "feature" of the mobx-react, because it can't observes part of the object – it observes object at all.
observer should not rerender as long as you do not replace the store with another instance. ( the injected props are then shallowly the same still and shouldcomponentupdate will return false in that case). so observer will only rerender if you used some observable property of the store in your render method.
Op do 7 jul. 2016 17:39 schreef Aria Fallah notifications@github.com:
@ifokeev https://github.com/ifokeev I'm actually unsure about this and don't have much experience with it, but if you can find more information or the root cause I can definitely work on fixing it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AriaFallah/mobx-store/issues/33#issuecomment-231117603, or mute the thread https://github.com/notifications/unsubscribe/ABvGhJWeZa8pM-1XgizxIO0EHE8iaYD4ks5qTR2lgaJpZM4JHM21 .
@mweststrate
if you used some observable property of the store in your render method.
How can I check this in the code?
@ifokeev
Have you tried https://github.com/mobxjs/mobx-react-devtools?
@AriaFallah
Have you tried https://github.com/mobxjs/mobx-react-devtools?
No, I'm trying to understand all of this. Now I understand that mobx will react only on properties in "trackable function" (i.e. render()). But I want to check it :)
@ifokeev
Well the dev tools log into the console whenever something rerenders. You should™ be able to check it with them.
@mweststrate @AriaFallah thanks for your help and fast responses.
I'm trying to use your beautiful code.
I check the code of
mobx-react
and think that if I add@observer(['store'])
and will use Provider<Provider store={store} />
it will affect componentWillReceiveProps on every update of the store and render again all components that observe the store.Am I wrong?
The same issue I added on mobx-react: https://github.com/mobxjs/mobx-react/issues/79
Also if use
react-redux
it will only update props that I mapped via mapStateToProps. Am I wrong with this too?So the main question is how to prevent unneeded rerender