-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 render内无法通过条件判断渲染this.props.children #11396
Comments
taro-bot2
bot
added
F-react
Framework - React
T-h5
Target - 编译到 H5
V-3
Version - 3.x
labels
Mar 4, 2022
等待热心的小伙伴解决问题中..., 有一些相关的 issues 可能帮助到你!
Thank you so much! |
不建议这么使用,因为在渲染小程序时,不可以在页面外渲染元素,同时渲染 h5 时也不应对页面作出修改,否则会导致一些额外的问题。尽管如此这个需求依旧有解法来实现,可以通过如下的方法来避开这个错误: import { Text } from '@tarojs/components'
import { Component } from 'react'
import './app.scss'
class App extends Component {
state = { userInfoSettled: false }
componentWillMount() {
setTimeout(() => {
this.setState({ userInfoSettled: true })
}, 1000);
}
render() {
return <>
<div style={{ display: this.state.userInfoSettled ? 'block' : 'none' }}>{this.props.children}</div>
{!this.state.userInfoSettled && <Text>Loading</Text>}
</>
}
}
export default App |
Vue3 版本呢? 如何解决这个问题. |
@ZakaryCode 那如果我需要异步加载config.json,然后把相关的data倒入redux,该如何处理呢?这就不能简单的display/hide了
请指点,thanks. |
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
相关平台
H5
浏览器版本: Chrome 98.0.4758.102
使用框架: React
复现步骤
修改app.tsx
期望结果
期望在app渲染前,先加载一些数据
实际结果
页面报错,提示“没有找到页面实例。”
环境信息
补充信息
可以理解成有些数据必须在app执行页面逻辑前获取。发现通过控制app里的render会报错。
请问应该如何解决,谢谢!
Taro版本3.3.19
The text was updated successfully, but these errors were encountered: