Completely rewrite connect() to offer advanced API, separate concerns, and (probably) resolve a lot of those pesky edge cases
See original GitHub issueI rewrote connect() and extracted a connectAdvanced() It now uses reselect to handle merging/caching of the state/props/dispatch. It also extracts out a connectAdvanced()
function that connect()
just delegates to.
I’m not quite ready to ready to submit a PR (still tweaking), but I’d like to suggest that this eventually become the new implementation.
It passes tests and linting, with the only breaking change to the existing API being related to the “advanced scenarios” for factories that require setting another options flag. (I haven’t figured out how to detect the factory methods automatically… will give it another go, but it’s been tricky given how radically different my approach is.) solved
Things I’m still need to do:
- support factorying map*ToProps functions without an explcit flag
- add more comments
- performance testing. the tests run slightly faster on my machine but we’re talking insignificant amounts (250ms vs 230ms). do performance tests exist for this?
- reconcile with pending pull requests, as there would be zero chance of a successful merge. I’ve already covered the changes and new features in several of them, but some of the others will need reimplemented.
- keep tinkering. there’s some functionality in
connect()
that I’d like to make reusable for someone who wants extend its functionality in userspace
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:53 (38 by maintainers)
Top Results From Across the Web
Idiomatic Redux: The History and Implementation of React ...
... #407: Completely rewrite connect() to offer advanced API, separate concerns, and (probably) resolve a lot of those pesky edge cases as a ......
Read more >Code Smell: Too Much Edge Case Handling - Pluralsight
Recently my team was working on an API endpoint that had an edge case. The happy path was to simply insert a record....
Read more >DevTools Debugging Tips And Shortcuts (Chrome, Firefox ...
In this article, Vitaly reviews useful features and shortcuts for debugging in Chrome, Firefox, Edge and Safari. Out of all the tools available ......
Read more >Moodle in English: Global Search rewrite - Moodle.org
I see that you're synchroneusly pushing data from the modules into the search index, while I'd like to do the reverse (indexing run...
Read more >IIS and ASP.NET Core Rewrite Rules for Static Files and Html ...
Kestrel has no support for host headers so you can't run multiple Kestrel instances on the same port, content caching, automatic static file ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s all good. The more scrutiny the better. Believe me, I’m more worried that I missed something than you are. haha.
Current benchmarks using jimbolla/react-redux-perf, all 6 tabs opens at once, 331 connected components each:
Frames per second:
Milliseconds to render a frame:
Same tests, this time with a Blocker component between the parent and children that always returns false for shouldComponentUpdate:
Frames per second:
Milliseconds to render a frame:
Fascinatingly, current did worse with the blocker component, while the rewrite does even better. I think this is because in the rewrite, my current bottleneck is the shallowEqual compare on ownProps. With the Blocker component, the old props === new props and avoids the complicated part of shallowEqual.
Haven’t had a chance to really dig through the code yet. My main suggestion at this point would be to document this to ridiculous levels:
I know that’s asking for a good chunk of work, but given that you’re proposing to swap out an entire existing implementation that’s been reasonably battle-tested with a brand-new codebase, the burden of proof is basically on you to fully justify the switch and make sure that it’s sufficiently maintainable in the future.