You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly, a memoized selector should _never_ use `state => state` as an input! That will force the selector to always recalculate.
229
229
:::
230
230
231
-
In typical Reselect usage, you write your top-level "input selectors" as plain functions, and use `createSelector` to create memoized selectors that calculate derived values:
231
+
In typical Reselect usage, you write your top-level "input selectors" as simple functions that just return values nested somewhere inside the state object. Then, you use `createSelector` to create memoized selectors that take one or more of these values as input and produce new derived values:
232
232
233
233
```js
234
-
conststate= {
235
-
a: {
236
-
first:5
237
-
},
238
-
b:10
239
-
}
240
-
241
-
constselectA1=state=>state.a.first
242
-
constselectB=state=>state.b
243
-
244
-
constselectResult=createSelector([selectA1, selectB], (a1, b) => {
Note that the second time we called `selectResult`, the "output selector" didn't execute. Because the results of `selectA1` and `selectB` were the same as the first call, `selectResult` was able to return the memoized result from the first call.
255
+
Note that the second time we called `selectTodosForCurrentUser`, the "output selector" didn't execute. Because the results of `selectTodos` and `selectCurrentUser` were the same as the first call, `selectTodosForCurrentUser` was able to return the memoized result from the first call.
0 commit comments