I am using useMemo and useContext hooks to store state of login and logout in my react native application.
import { AuthContext } from "./src/app/context";
export default () => {
const [isLoading, setIsLoading] = React.useState(true);
const [userToken, setUserToken] = React.useState(null);
const [userType, setUserType] = React.useState(null);
const [fontsLoaded, setFontsLoaded] = React.useState(false);
const authContext = React.useMemo(() => {
return {
signIn: (userType) => {
setUserToken("dummy");
setUserType(userType);
},
signUp: () => {
setIsLoading(false);
},
signOut: () => {
setIsLoading(false);
setUserToken(null);
},
showBottomNavigation: false
};
}, []);
React.useEffect(() => {
setTimeout(() => {
setIsLoading(false);
}, 1000);
}, []);
return (
<AuthContext.Provider value={authContext}>
<NavigationContainer>
<RootStackScreen userToken={userToken} userType={userType}/>
</NavigationContainer>
</AuthContext.Provider>
);
};
and context js file looks like below:
import React from "react";
export const AuthContext = React.createContext();
I wanted to update the showBottomNavigation(which is there in the useMemo object) from child component.
I'm new to these concepts, any suggestion how to update the showBottomNavigation and use it.