react-native中的异步条件组件呈现

react-native中的异步条件组件呈现,react-native,react-navigation,React Native,React Navigation,我正在尝试在我的RN应用程序中设置前端身份验证系统,但在呈现auth视图或主应用程序视图时遇到问题 根导航器是呈现auth视图或主视图的工具,我有一个变量signedIn来检查用户是否登录 const Stack=createStackNavigator(); 异步函数RootNavigator({signedIn}:{signedIn:boolean | undefined}){ 如果(!signedIn){ 返回( ); }否则{ 返回( ); } } 已登录变量通过我的主导航函数传递 导

我正在尝试在我的RN应用程序中设置前端身份验证系统,但在呈现auth视图或主应用程序视图时遇到问题

根导航器是呈现auth视图或主视图的工具,我有一个变量
signedIn
来检查用户是否登录

const Stack=createStackNavigator();
异步函数RootNavigator({signedIn}:{signedIn:boolean | undefined}){
如果(!signedIn){
返回(
);
}否则{
返回(
);
}
}
已登录变量通过我的主导航函数传递

导出默认函数导航({
配色方案,
身份
}: {
colorScheme:ColorSchemeName;
authStatus:布尔值|未定义
}) {
返回(
);
}
最后,authStatus变量来自我的主应用程序函数

导出默认函数App(){
const isLoadingComplete=useCachedResources();
const colorScheme=useColorScheme();
const[checkAuth,setCheckAuth]=useState(false);
const[signedIn,setSignedIn]=useState(false);
让[fontsLoaded]=使用字体({
Roboto_100;薄_斜体,
RobotoƐu,
Roboto_700Bold,
});
useffect(()=>{
异步函数fetchToken(){
试一试{
const token=await SecureStore.getItemAsync('access_token');
如果(令牌){
setSignedIn(真);
}否则{
设置信号(假);
}
}捕获(错误){
console.log(错误)
}最后{
setCheckAuth(真);
}
}
fetchToken()
}, [])
如果(!isLoadingComplete | | |!fontsLoaded)&&&!checkAuth){
返回;
}否则{
返回(
);
}
}
我当前在RootNavigator中收到一个typescript错误

'RootNavigator' cannot be used as a JSX component.
  Its return type 'Promise<Element>' is not a valid JSX element.

为什么将
RootNavigator
声明为异步函数?我怀疑将其更改为普通函数将解决typescript错误和执行错误。
Objects are not valid as a React child (found: object with keys {_U, _V, _W, _X}). If you meant to render a collection of children, use an array instead.