Home > Enterprise >  React.useContext appearing as undefined
React.useContext appearing as undefined

Time:11-13

This is my first time using the React context hooks in an app and my context default value keeps appearing as "undefined."

Troubleshooting so far:

  • I've made sure React.createContext is in a separate file (context.js)
  • I've made sure the child component is wrapped within the Provider
  • I'm providing a default value to React.createContext()

All of my code can be found in this CodeSandbox link below:

Edit React Context Troubleshooting (forked)

  • Related