setTimeout 在真实移动设备中立即运行

问题描述 投票:0回答:0

我使用 React Native 构建了一个带有自定义启动屏幕的 iOS 应用程序。然而,即使我将持续时间设置得更长,启动屏幕也会立即隐藏在真实设备上。它在模拟器上运行顺利。我该如何解决这个问题?

这是我的代码:

const [showSplash, setShowSplash] = useState(true)

 useEffect(() => {
    if (!isIos) {
    (async () => {
      await initFonts()
      setupRootStore().then(setRootStore)
      await checkRootDevice()
      initDayJs()

      await inAppUpdate()
    })()

    const timer = setTimeout(() => {
      setShowSplash(false)
    }, 5000)
  }, [])

我已经检查过这一点并确定我的应用程序未处于调试模式: 来源

reactjs react-native timer settimeout
© www.soinside.com 2019 - 2024. All rights reserved.