You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently we have a black list props to ignore but that is usually just to avoid unwanted warnings. If you pass down all props of the current component to its children the shouldComponentUpdate returns if any new prop received is different, which will cause the component to render even when it does not care about the prop that was changed.
Using a black list does not scale, it is better to be explicit and white list the props that matter for the current component so that we those are the only ones that can cause the component to re-render or raise warnings.
We can solve that issue on components define propTypes by using the the propTypes as a whitelist of the props that can cause this component to rerender.
Mixing e.g.
var Component = React.createClass({
mixins: [ImmutableMixin],
// this component only rerenders for changes on the state or on the props defined below
propTypes: {
symbol: React.PropTypes.string.isRequired
},
...
});
I think that same approach can work on with the higher order component.
var Component = React.createClass({
// The higher order immutable component only re renders for changes the propTypes
// defined by the wrapped component
propTypes: {
symbol: React.PropTypes.string.isRequired
},
...
});
exports.module = createImmutableContainer(Component);
Currently we have a black list props to ignore but that is usually just to avoid unwanted warnings. If you pass down all props of the current component to its children the shouldComponentUpdate returns if any new prop received is different, which will cause the component to render even when it does not care about the prop that was changed.
Using a black list does not scale, it is better to be explicit and white list the props that matter for the current component so that we those are the only ones that can cause the component to re-render or raise warnings.
We can solve that issue on components define
propTypes
by using the thepropTypes
as a whitelist of the props that can cause this component to rerender.Mixing e.g.
I think that same approach can work on with the higher order component.
cc: @akshayp @dmhood @redonkulus
The text was updated successfully, but these errors were encountered: