If we see in the doc example: https://reactnavigation.org/docs/auth-flow/ :
function SignInScreen() {
const [username, setUsername] = React.useState('');
const [password, setPassword] = React.useState('');
const { signIn } = React.useContext(AuthContext); // ????
return (
<View>
<TextInput
placeholder="Username"
value={username}
onChangeText={setUsername}
/>
<TextInput
placeholder="Password"
value={password}
onChangeText={setPassword}
secureTextEntry
/>
<Button title="Sign in" onPress={() => signIn({ username, password })} />
</View>
);
}
SignInScreen
is located in the same App.js. If we put out SignInScreen
as a new file SignInScreen.js, how to dispatch the signIn
from SignInScreen.js?
AuthContext.Provider
, but I'm not sure how to access the same AuthContext in SignInScreen.js? – Jacqui