Download reselect/docs/examples/createSelector/annotateResultFunction.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 642 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/createSelector/annotateResultFunction.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/createSelector/annotateResultFunction.ts
-
curl -L -o annotateResultFunction.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/reselect/docs/examples/createSelector/annotateResultFunction.ts
642 Bytes
| import { createSelector } from 'reselect' | |
| interface Todo { | |
| id: number | |
| completed: boolean | |
| } | |
| interface Alert { | |
| id: number | |
| read: boolean | |
| } | |
| export interface RootState { | |
| todos: Todo[] | |
| alerts: Alert[] | |
| } | |
| export const createAppSelector = createSelector.withTypes<RootState>() | |
| const selectTodoIds = createAppSelector( | |
| // Type of `state` is set to `RootState`, no need to manually set the type | |
| state => state.todos, | |
| // ❌ Known limitation: Parameter types are not inferred in this scenario | |
| // so you will have to manually annotate them. | |
| // highlight-start | |
| (todos: Todo[]) => todos.map(({ id }) => id) | |
| // highlight-end | |
| ) | |