State Management · Middle · Question 5 of 75

What's the purpose of the third argument init in useReducer(reducer, arg, init)?

Explanation

useReducer(reducer, username, createInitialState) avoids recomputing an expensive initial state on every render - like a lazy initializer in useState. init can also be reused to reset the state.

Further reading

Problem with a question

State Management · Middle · question 5

Test yourself

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

Take this quiz