如果我们在文档示例中看到: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
位于同一个App.js中。如果我们将SignInScreen.jsSignInScreen
作为一个新文件发布,如何从SignInScreen.js调度?signIn