Last active
February 3, 2020 13:47
-
-
Save Franpastoragusti/1a8c01000bfe80481b353aadecc7baf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* /src/providers/authProvider.jsx */ | |
import React, {Component} from "react"; | |
import AuthService from "../services/authService"; | |
const AuthContext = React.createContext({ | |
signinRedirectCallback: () => ({}), | |
logout: () => ({}), | |
signoutRedirectCallback: () => ({}), | |
isAuthenticated: () => ({}), | |
signinRedirect: () => ({}), | |
signinSilentCallback: () => ({}), | |
createSigninRequest: () => ({}) | |
}); | |
export const AuthConsumer = AuthContext.Consumer; | |
export class AuthProvider extends Component { | |
authService; | |
constructor(props) { | |
super(props); | |
this.authService = new AuthService(); | |
} | |
render() { | |
return <AuthContext.Provider value={this.authService}>{this.props.children}</AuthContext.Provider>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you go about adding Redux to this provider? https://react-redux.js.org/api/provider
Do you wrap the whole AuthProvider in a Redux Provider or do you customize this AuthProvider to use the Redux store.