Redux: Document performance implications of ownProps and a workaround

Created on 12 Apr 2016  路  6Comments  路  Source: reduxjs/redux

Relying on ownProps in mapStateToProps disables some optimizations in React Redux.
We should mention this in the docs of both projects, and also include this neat tip on how ownProps can be avoided for many cases.

Contributions are welcome!

docs help wanted

Most helpful comment

In fact a lot of thinking in https://github.com/mweststrate/redux-todomvc/pull/1 is non-obvious to beginners and even advanced users. We should have an optimization guide that explains _how_ to find the optimization sweet spots and use them.

All 6 comments

Example of this in practice: https://github.com/mweststrate/redux-todomvc/pull/1/commits/e5d25f047ff62c1eddd2b3ad2a62a7b4638ee52e
Gives ~3x perf boost in my testing.

In fact a lot of thinking in https://github.com/mweststrate/redux-todomvc/pull/1 is non-obvious to beginners and even advanced users. We should have an optimization guide that explains _how_ to find the optimization sweet spots and use them.

Yeah. That and a "Structuring Reducers" recipe would be great additions to the docs. I'm kinda busy at the moment, but might be able to help out at some point.

As a side note, I'm rather amused to see that you've adopted strictly passing IDs to children as a viable option for some use cases, given a couple of your earlier comments against it. :)

Obviously reasons to do both, depending on the situation.

It really depends on whether I鈥檓 trying to keep components more reusable or optimize the hell out of their updates.

Great! thanks @gaearon

Let's roll this up into #1783. It should definitely be covered there!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mickeyreiss-visor picture mickeyreiss-visor  路  3Comments

vslinko picture vslinko  路  3Comments

benoneal picture benoneal  路  3Comments

ms88privat picture ms88privat  路  3Comments

parallelthought picture parallelthought  路  3Comments