Branch mixin does not update this.cursors and this.facets in componentWillReceiveProps
davidtinker opened this issue · 2 comments
davidtinker commented
This causes problems with components using cursor paths with properties in them when they attempt to change the data via this.cursors.
cursors: function(props) {
return {data: ['views', 'users', props.user.id, 'balance']};
},
Elsewhere:
this.cursors.data.set(data);
Once properties have changed this.cursors will point at the wrong set of cursors.
The fix in mixins.js is simple:
componentWillReceiveProps: function componentWillReceiveProps(props) {
if (!this.__facet) return;
this.__facet.refresh([props, this.context]);
this.cursors = this.__facet.cursors;
this.facets = this.__facet.facets;
this.setState(this.__facet.get());
}
I can send a PR if you like but its only 2 lines of code to add.
Yomguithereal commented
Hello @davidtinker. You are right indeed. I forgot this. Would it be possible for you to sketch a PR fixing the issue for mixins and higher-order components etc. also please?
Yomguithereal commented
This should be fixed with the latest version of the library. Do you need a retro-compatible fix?