Click in order · JavaScript and React course · Module 4: Context API and useReducer
Reducer Structure
Arrange the structure of a space reducer:
Items to click
- switch (action.type) {
- case 'LAUNCH_SHIP': return { ...state, ships: [...state.ships, action.payload] };
- } }
- default: return state;
- function spaceReducer(state, action) {
You can check the correct answer by solving this task in the CodeWorlds game.