1×
Become a member
to unlock all features
Autoplay

    Wrap Our React Application in an AuthProvider Component

    reactReact

    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.