Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何在React Native中使用AWS Amplify在sigin后呈现自定义组件?_Reactjs_React Native_Expo_Aws Amplify - Fatal编程技术网

Reactjs 如何在React Native中使用AWS Amplify在sigin后呈现自定义组件?

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> 您需要

我想在登录后使用放大反应ui组件渲染我的应用程序。 下面是我的代码的样子

    <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更好地处理和呈现正确的组件