react-code-dataset / reselect /docs /examples /development-only-stability-checks /identityFunctionCheck.ts
Download reselect/docs/examples/development-only-stability-checks/identityFunctionCheck.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 533 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/development-only-stability-checks/identityFunctionCheck.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/development-only-stability-checks/identityFunctionCheck.ts
-
curl -L -o identityFunctionCheck.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/development-only-stability-checks/identityFunctionCheck.ts
533 Bytes
| import { createSelector } from 'reselect' | |
| interface RootState { | |
| todos: { id: number; completed: boolean }[] | |
| alerts: { id: number; read: boolean }[] | |
| } | |
| // Create a selector that checks to see if the result function is an identity function. | |
| const selectTodos = createSelector( | |
| // ✔️ GOOD: Contains extraction logic. | |
| [(state: RootState) => state.todos], | |
| // ❌ BAD: Does not contain transformation logic. | |
| todos => todos, | |
| // Will override the global setting. | |
| { devModeChecks: { identityFunctionCheck: 'always' } } | |
| ) | |