DEV Community

Discussion on: React Hooks: How to create and update Context.Provider

Collapse
 
nickempetvee profile image
NickEmpetvee • Edited

Great tutorial. I've run into an issue. Would you mind providing a little help? I've copied your code line for line, but into an environment created by create-react-app. Code here: codesandbox.io/s/3xxykj5wjq

The error I get is:

TypeError
React.useReducer is not a function
ContextOneProvider
/src/ContextOne.js:25:32
  22 | 
  23 | function ContextOneProvider(props) {
  24 |   // [A]
> 25 |   let [state, dispatch] = React.useReducer(reducer, initialState);
     |                                ^
  26 |   let value = { state, dispatch };
  27 | 
  28 |   // [B]
Collapse
 
nickempetvee profile image
NickEmpetvee

Solved! I was on an earlier version of React.