3 ms·
Yes, that's how for I've got, too. But then you have a problem if your React component has multiple attributes. Suddenly your check beckomes much larger: ret
by jannes 12y ago
Yes, that's how for I've got, too. But then you have a problem if your React component has multiple attributes. Suddenly your check beckomes much larger:
return (nextProps.attr1 !== this.props.attr1 ||
nextProps.attr2 !== this.props.attr2 ||
nextProps.attr3 !== this.props.attr3 ||
nextProps.attr4 !== this.props.attr4);
Which would result in a lot of boilerplate code if you had to do this for every single attribute in every component in your application. It would be much simpler to just do this check:
return nextProps !== this.props;
But that's impossible if you're using JSX, because the JSX compiler automatically inserts a normal JavaScript object into your code, instead of an immutable object from this library.
So from my point of view this immutable-js library and JSX seem incompatible, which is kind of weird since Facebook apparently uses JSX internally for their React code.
- augustl 12y agoMyComponent({realProps: immutable props}) comes to mind.. In a flux application you typically always ask flux for the state, though, so it becomes this.getFlux().myThing.
- vjeux 12y agoPureRenderMixin[1] is doing this without having you to enumerate all the props [1] http://facebook.github.io/react/docs/pure-render-mixin.html http://facebook.github.io/react/docs/pure-render-mixin.html