Closed
Description
Since connected components are PureComponents, it is important for mapStateToProps to avoid creating new objects with identical data every time. If this happens, it will cause unnecessary re-renders, leading to bad performance.
Writing a rule to catch all of these scenarios might be too difficult, but there is probably a subset of scenarios that could be trivially linted against. Consider the following mapStateToProps:
function mapStateToProps(state) {
return {
foo: {
bar: state.foobar,
},
};
}
What do you think about adding a rule that flags a few of these simple cases?
Metadata
Metadata
Assignees
Labels
No labels