v5.0.0-alpha.2 #614
markerikson
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This alpha release updates
createSelector
to run an extra one-time check for input selector stability in development builds, and updates the build artifacts to include sourcemaps and a browser-ready ESM production bundle.Changelog
Development Input Stability Checks
Reselect uses two levels of memoization. The first level checks if any of the actual arguments have changed, and the second sees if the values extracted by the input functions have changed.
If an input function always returns a new reference, like
(state) => ({a: state.a, b: state.b})
or(state) => state.items.map()
, that will cause the selector to never memoize properly. This is a bug, similar conceptually to always returning a new reference inuseSelector()
, or always including a new reference inuseEffect
's dependencies array.Since this is a common mistake, we've added a development mode check to catch this. By default,
createSelector
will now run try executing the memoization function twice during the first call to the selector. If the result appears to be different, it will log a warning with the arguments and the two different sets of extracted input values.You can configure this behavior in two ways: by passing an
inputStabilityCheck
option directly tocreateSelector
, or by importing the globalsetInputStabilityCheckEnabled()
function:Build Artifact Changes
We now include a
reselect.browser.mjs
ESM artifact has been compiled for production settings and is ready for use as an ES module in browsers.We also have updated the
reselect.legacy-esm.js
artifact to transpile syntax for compat with Webpack 4.What's Changed
Full Changelog: v5.0.0-alpha.1...v5.0.0-alpha.2
This discussion was created from the release v5.0.0-alpha.2.
Beta Was this translation helpful? Give feedback.
All reactions