Skip to content
Advertisement

I am trying to use the react hook useContext() but its not working

i am trying to use the useContext hook for the first time and i am not getting the name displayed on screen, i have never used useContext ever before, so pls a little bit of explination of my mistake will be appreciated. Here is the code: (edit: added App.js)

AuthContext.js

JavaScript

Header.js

JavaScript

App.js

JavaScript

i have added the error screenshotenter image description here

Advertisement

Answer

JavaScript

Instead of the above, you have to import the AuthProvider like below since you have used named export for AuthProvider in the AuthContext.js file.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement