Question · JavaScript and React course · Module 4: Context API and useReducer

Immutability in Reducers

Why must reducer functions be 'pure functions' and not mutate state?

Answer options

  • For better application performance
  • React compares object references to detect changes
  • useReducer requires immutable objects
  • It's just a convention with no functional significance

You can check the correct answer by solving this task in the CodeWorlds game.