v7.2.0
This release fixes two bugs, an algorithmic problem with unsubscribing components and a memory leak with connect
. It also has optimizations for production bundle size, and adds a couple small improvements to developer readability while debugging.
Bug Fixes
connect
in v7 is implemented using hooks, and the hooks usage captures numerous values from the surrounding scope. We received a PR informing us that the way we were capturing these values would likely result in a copy of the first version of its props being kept alive indefinitely.
This memory leak has been fixed by extracting a custom hook that receives all the necessary values as arguments, so that they're not captured via closure.
We also received a PR letting us know that the unsubscribe logic had a quadratic algorithm in it, as removing a subscriber would use an indexOf(listener)
check to remove that callback. If there were a large number of subscribers, that line's runtime would increase rapidly, causing slowdowns.
This algorithm has been replaced with tracking subscribers via a linked list, which drastically improves the runtime of this section of the code even with large numbers of subscribers.
Thanks to @larrylin28 and @wurstbonbon for finding these bugs and submitting PRs to fix them!
Bundle Size Improvements
We've made a number of small tweaks to the codebase to improve the ability of bundlers to shake and minimize the final included size in a bundle. The net result is that react-redux@7.2.0
is smaller than 7.1.3, dropping 1.3K min and 0.6K min+gzip. (In fact, it's even smaller than the pre-hooks 7.0.0 when gzipped!)
Thanks to @Andarist for doing most of the work on this!
Debugging Improvements
The ReactReduxContext
instance now has a displayName
set, so it should show up in the React DevTools as ReactRedux.Provider
.
Also, when an error is caught in useSelector
and re-thrown, we now append the original stack trace.
Thanks to @pieplu and @r3dm1ke for these!
Changes
- Fix memory leak issue with
UseEffect
(@larrylin28 - #1506) - Optimize createListenerCollection (@wurstbonbon - #1523)
- Rethrowing original errors thrown in selector functions (@Andarist - #1474)
- Remove invariant in favor of doing NODE_ENV checks directly (@Andarist - #1472)
- Wrap .propTypes and .displayName assignments with DEV check (@Andarist - #1471)
- Add pure annotations to help with DCE (@timdorr - 5e0c50d)
- Inline this function. (@timdorr - 58ae5ed)
- Add a displayName on ReactReduxContext (@pieplu - #1462)