Skip to content

Commit 736bd9f

Browse files
authored
Update useReducer hook reference example
The `initialState` prop that may be passed to the `Counter` component shadows the `initialState` constant declared at the top of the example. If the example code is run without passing `initialState` the code will fail with the error `Uncaught TypeError: Cannot read property 'count' of undefined`. Before: https://codesandbox.io/s/jzm0k3o4y9 After: https://codesandbox.io/s/506v6j107k
1 parent 8de5aff commit 736bd9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/docs/hooks-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function reducer(state, action) {
226226
}
227227
}
228228

229-
function Counter({initialState}) {
229+
function Counter() {
230230
const [state, dispatch] = useReducer(reducer, initialState);
231231
return (
232232
<>

0 commit comments

Comments
 (0)