Created
November 5, 2020 12:40
-
-
Save amandeepmittal/a801751e91477747264eeb4968ede11d 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
import 'react-native-gesture-handler'; | |
import React from 'react'; | |
import RootNavigator from './src/navigation/RootNavigator'; | |
import { AuthenticatedUserProvider } from './src/navigation/AuthenticatedUserProvider'; | |
const App = () => { | |
return ( | |
<AuthenticatedUserProvider> | |
<RootNavigator /> | |
</AuthenticatedUserProvider> | |
); | |
}; | |
export default App; |
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
/** | |
* This provider is created | |
* to access user in whole app | |
*/ | |
import React, { createContext, useState } from 'react'; | |
export const AuthenticatedUserContext = createContext({}); | |
export const AuthenticatedUserProvider = ({ children }) => { | |
const [user, setUser] = useState(null); | |
return ( | |
<AuthenticatedUserContext.Provider value={{ user, setUser }}> | |
{children} | |
</AuthenticatedUserContext.Provider> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment