当EXPO应用程序出现在前台时,它会在iOS上闪烁,但安卓系统并没有问题。它是由世博会自动创建的(反应导航)

当EXPO应用程序出现在前台时,它会在iOS上闪烁,但安卓系统并没有问题。它是由世博会自动创建的(反应导航),ios,react-native,expo,Ios,React Native,Expo,我已经用Expo(React Navigation 5.0)创建了我的应用程序,并将“createBottomTabNavigator”更改为“createMaterialBottomTabNavigator”。但当它在前面的时候,就像它在后面一样,它在眨眼 这是我启动应用程序的终端捕获屏幕。 这是只由我更改的代码 import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';

我已经用Expo(React Navigation 5.0)创建了我的应用程序,并将“createBottomTabNavigator”更改为“createMaterialBottomTabNavigator”。但当它在前面的时候,就像它在后面一样,它在眨眼

这是我启动应用程序的终端捕获屏幕。

这是只由我更改的代码

import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';


const BottomTab = createMaterialBottomTabNavigator<BottomTabParamList>();
从'@react navigation/material bottom tabs'导入{createMaterialBottomTabNavigator};
const BottomTab=createMaterialBottomTabNavigator();
其余代码由“expo Int my app”自动生成

这是App.tsx

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import useCachedResources from './hooks/useCachedResources';
import useColorScheme from './hooks/useColorScheme';
import Navigation from './navigation';

export default function App() {
  const isLoadingComplete = useCachedResources();
  const colorScheme = useColorScheme();

  if (!isLoadingComplete) {
    return null;
  } else {
    return (
      <SafeAreaProvider>
        <Navigation colorScheme={colorScheme} />
        <StatusBar />
      </SafeAreaProvider>
    );
 }
从“世博会状态栏”导入{StatusBar};
从“React”导入React;
从“react native safe area context”导入{SafeAreaProvider};
从“./hooks/useCachedResources”导入useCachedResources;
从“./hooks/useColorScheme”导入useColorScheme;
从“./Navigation”导入导航;
导出默认函数App(){
const isLoadingComplete=useCachedResources();
const colorScheme=useColorScheme();
如果(!isLoadingComplete){
返回null;
}否则{
返回(
);
}
}

这是index.tsx

import { NavigationContainer, DefaultTheme, DarkTheme } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import * as React from 'react';
import { ColorSchemeName } from 'react-native';
import NotFoundScreen from '../screens/NotFoundScreen';
import { RootStackParamList } from '../types';
import BottomTabNavigator from './BottomTabNavigator';
import LinkingConfiguration from './LinkingConfiguration';

// If you are not familiar with React Navigation, we recommend going through the
// "Fundamentals" guide: https://reactnavigation.org/docs/getting-started
export default function Navigation({ colorScheme }: { colorScheme: ColorSchemeName }) {
  return (
    <NavigationContainer
      linking={LinkingConfiguration}
      theme={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
     <RootNavigator />
    </NavigationContainer>
  );
}

// A root stack navigator is often used for displaying modals on top of all other content
// Read more here: https://reactnavigation.org/docs/modal
const Stack = createStackNavigator<RootStackParamList>();

function RootNavigator() {
  return (
    <Stack.Navigator screenOptions={{ headerShown: false }}>
      <Stack.Screen name="Root" component={BottomTabNavigator} />
      <Stack.Screen name="NotFound" component={NotFoundScreen} options={{ title: 'Oops!' }} />
    </Stack.Navigator>
  );
}
从'@react navigation/native'导入{NavigationContainer,DefaultTheme,DarkTheme};
从'@react navigation/stack'导入{createStackNavigator};
从“React”导入*作为React;
从“react native”导入{ColorSchemeName};
从“../screens/NotFoundScreen”导入NotFoundScreen;
从“../types”导入{RootStackParamList};
从“/BottomTabNavigator”导入BottomTabNavigator;
从“/LinkingConfiguration”导入LinkingConfiguration;
//如果您不熟悉React导航,我们建议您浏览
//《基本原理》指南:https://reactnavigation.org/docs/getting-started
导出默认函数导航({colorScheme}:{colorScheme:ColorSchemeName}){
返回(
);
}
//根堆栈导航器通常用于在所有其他内容之上显示模态
//请在此处阅读更多信息:https://reactnavigation.org/docs/modal
const Stack=createStackNavigator();
函数RootNavigator(){
返回(
);
}


我希望任何人都能帮助我这是react native中的一个已知错误。

尝试用以下代码替换useColorScheme挂钩(hooks/useColorScheme.ts):

从'react native'导入{Appearance,ColorSchemeName};
从“react”导入{useffect,useRef,useState};
导出默认函数useColorScheme(延迟=500):不可为空{
const[colorScheme,setColorScheme]=useState(外观.getColorScheme());
让timeout=useRef(null).current;
useffect(()=>{
外观.addChangeListener(onColorSchemeChange);
return()=>{
resetCurrentTimeout();
外观:removeChangeListener(onColorSchemeChange);
};
}, []);
函数onColorSchemeChange(首选项:外观.外观首选项){
resetCurrentTimeout();
超时=设置超时(()=>{
setColorScheme(preferences.colorScheme);
},延误);
}
函数resetCurrentTimeout(){
如果(超时){
clearTimeout(超时);
}
}
将colorScheme返回为不可空;

}
它工作得很好。事实上,我几乎完成了myapp的代码,我正准备发布它。如果没有您的解决方案,主题将只是“轻”。谢谢维塔利T!!!你好,@Vitali T.我有。你能再帮我一次吗?