Reactjs 如何在React Native中使用AWS Amplify在sigin后呈现自定义组件?
我想在登录后使用放大反应ui组件渲染我的应用程序。 下面是我的代码的样子Reactjs 如何在React Native中使用AWS Amplify在sigin后呈现自定义组件?,reactjs,react-native,expo,aws-amplify,Reactjs,React Native,Expo,Aws Amplify,我想在登录后使用放大反应ui组件渲染我的应用程序。 下面是我的代码的样子 <View style={styles.container}> <Logo /> <Authenticator usernameAttributes="email"> <Home /> </Authenticator> </View> 您需要
<View style={styles.container}>
<Logo />
<Authenticator usernameAttributes="email">
<Home />
</Authenticator>
</View>
您需要将某些内容传递给主组件
const Home = (props) => {
if (props.authState === 'signedIn') {
return <Text>Home</Text>;
} else {
return <></>;
}};
大概是这样的:
<View style={styles.container}>
<Logo />
<Authenticator usernameAttributes="email">
<Home authState={authState}/>
</Authenticator>
</View>
其中,authState接收一个变量,该变量指定用户是否作为字符串登录,以便您能够使用props对其进行比较。authState==='signedIn'您可以使用WithAuthenticator HOC更好地处理和呈现正确的组件