-
-
Notifications
You must be signed in to change notification settings - Fork 349
componentWillReceiveProps not working? #281
Comments
EDIT: I am accessing these via |
|
By the looks of it |
Followed by
:) And from Mobx docs:
|
@urugator what if it's not context updating? i.e. I call function that sets new value in mobx class, exactly how docs show and I expect to receive new value with it flowing down through Reason for me using provider is to have global store that is easily accessible through |
No it's what it's made for. I was just trying to explain when and why |
@urugator
Any idea how to handle this(I want to compare existing and nextProps and do something if their value is not same)? |
There is no such concept as prev and next state in MobX, there is just current state. You can always compare prev and next props in React component. What you can do is to transform your observable value change to prop value change: inject(() => ({
isLoading: store.myStore.isLoading.get()
}))(props => React.createElement("div", null, props.isLoading))
// the same can be done without inject, you will need 2 components - parent using observable and child using plain prop However the need to compare prev and next state seems a bit fishy in the first place... |
So, what is the best practice of implementing logic that requires observing props change? |
the same problem, it it possible to support the componentWillReceiveProps running while the observable value changed? |
This problem is still unsolved, any work around ? |
This issue is closed, but normal mobx mechanisms apply; use reaction or observe to detect prop changes, or just split up your component in a plain and mobx part (for example by using This issue is closed, for follow up questions please open fresh issues with concrete use cases |
for some reason I can't get
componentWillReceiveProps
to trigger when mobx props are updated, yetcomponentWillUpdate
gets triggered just fine. Any suggestions on what could be causing this?The text was updated successfully, but these errors were encountered: