简体   繁体   English

EXPO应用程序在iOS上出现在前面时会闪烁,但Android没问题。 它是由 EXPO 自动创建的(反应导航)

[英]EXPO app is blink at iOS when it is appeared to front but Android is no problem. It was created automatically by EXPO (react navigation)

I have created my app with Expo(React Navigation 5.0) and changed "createBottomTabNavigator" to "createMaterialBottomTabNavigator".我已经使用 Expo(React Navigation 5.0) 创建了我的应用程序,并将“createBottomTabNavigator”更改为“createMaterialBottomTabNavigator”。 But When it is at front as soon as it was at back, it is blink.但是当它在后面时就在前面时,它是眨眼。

This is the captured screen of terminal for my initiating app.这是我的启动应用程序的终端捕获屏幕。 creating my app by EXPO通过 EXPO 创建我的应用程序

This is the code which is only changed by me.这是仅由我更改的代码。

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


const BottomTab = createMaterialBottomTabNavigator<BottomTabParamList>();

The rest of code is automatically made by "expo init my-app"其余代码由“expo init my-app”自动生成

This is App.tsx这是 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>
    );
 }

} }

and this is index.tsx这是 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>
  );
}

This is blinking captured video这是闪烁的捕获视频

I hope anyone can help me我希望任何人都可以帮助我

It is a known bug in react-native.这是 react-native 中的一个已知错误。 https://github.com/facebook/react-native/issues/28525 https://github.com/facebook/react-native/issues/28525

Try to replace useColorScheme hook (hooks/useColorScheme.ts) with the following code:尝试用以下代码替换 useColorScheme 钩子 (hooks/useColorScheme.ts):

 import { Appearance, ColorSchemeName } from 'react-native'; import { useEffect, useRef, useState } from 'react'; export default function useColorScheme(delay = 500): NonNullable<ColorSchemeName> { const [colorScheme, setColorScheme] = useState(Appearance.getColorScheme()); let timeout = useRef<NodeJS.Timeout | null>(null).current; useEffect(() => { Appearance.addChangeListener(onColorSchemeChange); return () => { resetCurrentTimeout(); Appearance.removeChangeListener(onColorSchemeChange); }; }, []); function onColorSchemeChange(preferences: Appearance.AppearancePreferences) { resetCurrentTimeout(); timeout = setTimeout(() => { setColorScheme(preferences.colorScheme); }, delay); } function resetCurrentTimeout() { if (timeout) { clearTimeout(timeout); } } return colorScheme as NonNullable<ColorSchemeName>; }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 密钥签名 Windows 用于 React Expo 应用程序? - Android key signing on Windows for React Expo app? 为什么 IOS 和 Android 之间的 header 行为存在差异 - ZC29F23F279126757BA18ECCF74D0 应用程序 - Why is there a difference in header behaviour between IOS and Android - Expo Application/React Navigation 已发布 expo 应用程序,在 iOS 上的 expo 中运行 - Published expo app, running in expo on iOS React Navigation:如何在 expo modal 上放置一个 iOS 风格的可关闭栏 - React Navigation: How to put an iOS style dismissible bar on expo modal Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android - Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android 使用Expo iOS应用测试纯反应本机代码 - Use Expo iOS app to test pure react native code React Native Expo iOS应用程序 - 尝试修改info.plist - React Native Expo iOS app - trying to modify info.plist Expo react本机Facebook登录在iOS独立应用程序上崩溃 - Expo react native Facebook login crashes on iOS standalone app 在 Windows 计算机上为 React Native App 运行 expo build:ios 时出错 - Error running expo build:ios on Windows Computer for React Native App Expo react本机应用程序图像在testflight ios上无法正常工作 - Expo react native app image not work properly on testflight ios
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM