Wrap Our React Application in an AuthProvider Component

InstructorIan Jones

Share this video with your friends

Send Tweet

We wrap our app in src/index.js file with the AuthProvider component. Then we call React.useContext in our App component to grab the login and status in our AuthContext.

status will be an object where the keys in the object will be the services that the user is logged into. So, we can check status.github to check if the user is logged into GitHub.

If the user isn't logged into GitHub, we display JSX with a prompt to log in. We create a button component where the onClick handler calls our login function with the string of 'github' passed in.

Shawn Petros
~ 3 months ago

this change is necessary for the call to github to complete correctly, otherwise everything else is good!