Closed
Description
First at all, thank for redux-toolkit ❤️
One thing that seems a lot of boilerplate for me in redux is to have a lot of selector and all the boilerplate with reselect to access the state or create derivate values
Here's a rough initial API proposal:
const todosSlice = createSlice({
name: "todos",
initialState: { todos: [], filter: "ALL" },
reducers: { ... },
derived: {
total: state => state.todos.length,
currentTodos: state => state.todos.filter(todo => todo.status === state.filter)
}
})
And inside of the component
function Todos(props) {
const { total, currentTodos, filter} = useSelector(todosSlice.selectors)
return ...
}
Maybe it couldn’t be possible but in this way I think redux-toolkit could help to reduce a lot of code
What are everyone's thoughts?
Metadata
Metadata
Assignees
Labels
No labels