react-redux v7.1.0-alpha.5 Release Notes

Release Date: 2019-05-20 // 7 months ago
  • We're still making changes to our hooks APIs, but I'm hopeful that we're getting close to having the behavior nailed down.

    🚀 This release makes three specific changes to useSelector:

    • 🚚 The deps array has been removed. If you want to ensure the same selector function reference is used, you should memoize it yourself.
    • 0️⃣ The default equality check used to determine if a re-render is needed is now a strict === check, instead of a shallow equality check.
    • useSelector now accepts a comparison function as an optional second argument, similar to how React.memo() works conceptually. You may pass your own comparison function to customize how useSelector determines if a re-render is necessary.

    In addition, we now export our internal shallowEqual utility function. If you want to return to the prior equality behavior, you may pass that as the equality comparison function:

    import { shallowEqual, useSelector } from "react-redux"// laterconst selectedData = useSelector(mySelector, shallowEqual)
    

    The optional comparison function also enables using something like Lodash's _.isEqual() or Immutable.js's comparison capabilities.

    Changes