React · Junior · Question 46 of 75

What does createSlice generate?

Explanation

createSlice({ name: 'todos', initialState, reducers: { added(state, action) {...} } }) returns todosSlice.reducer and todosSlice.actions.added with the type 'todos/added'. This removes classic Redux boilerplate with type constants and switch.

Further reading

Problem with a question

React · Junior · question 46

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz