The Rematch select plugin
Selectors are a really good performance booster for our Rematch/Redux applications. A selector is simply a function that accepts the root state as an argument and returns data that is derived from that root state.
Reselect (https://github.com/reduxjs/reselect) is the official library for creating memoized and composable selector functions, and the Rematch select library is built on top of Reselect.
But why are selectors performance boosters? Because selectors aren't recomputed unless one of their arguments changes.
Installing and configuration
To install @rematch/select
, you can use yarn
and install it as follows:
yarn add @rematch/select
This package is just 596 bytes, so it has a minimal impact on our bundle size. None of the official Rematch plugins is more than 600 bytes in size.
This plugin accepts one optional argument, which is an object with the following properties:
sliceState
: Sometimes our store is not a plain...