An unmatched action must return the state unchanged.
Acceptance criteria
- 1.Clicking should show 1.
An unmatched action must return the state unchanged.
function reducer(state, action) { if (action.type === "add") return state + 1 return state } function App() { const [count, dispatch] = React.useReducer(reducer, 0) return ( <div> <p id="value">{count}</p> <button id="inc" onClick={() => dispatch({ type: "inc" })}>add</button> </div> ) } const root = ReactDOM.createRoot(document.getElementById("root")) root.render(<App />)
Output ready when you are
Press Run to render your code, or Submit to validate your solution.