Skip to content

Instantly share code, notes, and snippets.

@ICeZer0
Created April 11, 2020 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ICeZer0/c3136e74fa1d0ae5ab63941263a3a28f to your computer and use it in GitHub Desktop.
Save ICeZer0/c3136e74fa1d0ae5ab63941263a3a28f to your computer and use it in GitHub Desktop.
const authContextValue = useMemo(
() => ({
signIn: async data => {
if (
data &&
data.emailAddress !== undefined &&
data.password !== undefined
) {
dispatch({ type: 'SIGN_IN', token: 'Token-For-Now' });
} else {
dispatch({ type: 'TO_SIGNIN_PAGE' });
}
},
signOut: async data => {
dispatch({ type: 'SIGN_OUT' });
},
signUp: async data => {
if (
data &&
data.emailAddress !== undefined &&
data.password !== undefined
) {
dispatch({ type: 'SIGNED_UP', token: 'dummy-auth-token' });
} else {
dispatch({ type: 'TO_SIGNUP_PAGE' });
}
}
}),
[]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment