Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App.tsx中异步获取到数据前先加载loading组件,有了数据再显示children,显示没有找到页面实例 #11019

Closed
jinglun2019 opened this issue Jan 1, 2022 · 4 comments
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x

Comments

@jinglun2019
Copy link

相关平台

H5

浏览器版本: Firefox 96.0b9 (64 位)
使用框架: React

复现步骤

编译后显示“没有找到页面实例”

APP.TS文件

type AppProps = React.PropsWithChildren<{}>

function App({ children }: AppProps) {
  const [isLoaded, setIsLoaded] = useState(false)
  useEffect(() => {
    setTimeout(() => {
      setIsLoaded(true)
    }, 3000)
  }, [])
  return isLoaded ? children : <View>loading</View>
}

export default App

期望结果

正常运行

实际结果

运行报错

环境信息

👽 Taro v3.3.16


  Taro CLI 3.3.16 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 16.12.0 - C:\Program Files\nodejs\node.EXE
      npm: 8.1.0 - C:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x labels Jan 1, 2022
@lin593
Copy link

lin593 commented Jan 7, 2022

解决了吗,这种写法可以的吗

@jinglun2019
Copy link
Author

解决了吗,这种写法可以的吗

没解决,也没人回。我打算用swr.js这个库了,这样也不需要开始的时候加载全局信息

@hepeng10
Copy link

遇到相同的问题,不知道能解决不。。。

@ZakaryCode
Copy link
Contributor

可以参考这里的写法

@ZakaryCode ZakaryCode moved this to Done in H5 Apr 10, 2023
@ZakaryCode ZakaryCode added this to H5 Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-h5 Target - 编译到 H5 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

4 participants