[英]React-Native 'Cannot add a child that doesn't have a YogaNode to a parent without a measure function!'
App.js renders a reusable external component Fade
with its children component. App.js使用其子组件呈现可重用的外部组件Fade
。 The animation in Fade
is executed when a children is confirmed with {this.state.visible ? children : null}
当用{this.state.visible ? children : null}
确认孩子时,执行Fade
的动画{this.state.visible ? children : null}
{this.state.visible ? children : null}
in its render function. {this.state.visible ? children : null}
在其渲染函数中。 After debugging it, I believe the error is caused by the ternary operator, due to the way it is defined in the render function of Fade
. 调试之后,我相信该错误是由三元运算符引起的,这是由于Fade
的render函数中定义的方式所致。
My issue is that I don't know how to correctly wrap this ternary operator in the render. 我的问题是我不知道如何在渲染器中正确包装此三元运算符。 I have tried <Text>
and <View>
without success. 我尝试了<Text>
和<View>
但没有成功。 Does anyone know how to fix this? 有谁知道如何解决这一问题?
Thank you in advance. 先感谢您。
App.js render App.js呈现
<Container>
<Fade visible={display.bus}> {renderIf(display.bus, <BusTemplate />)} </ Fade>
</Container>
Fade.js render Fade.js渲染
<Animated.View style={this.state.visible ? combinedStyle : containerStyle}>
{this.state.visible ? children : null}
</Animated.View>
Bus.js render Bus.js渲染
<Container>
<Image source={require("./scenerios/Bus.png")} style={styles.MainContainer}>
</Image>
</Container>
Ciao Diego, once I read this problem is related with the if
check on an undefined
var. Ciao Diego,一旦我阅读了此问题,便与对undefined
var的if
检查有关。 It could be your case with this.state.visible
. 使用this.state.visible
可能是您的情况。
Another chance is by wrapping your component in a View
tag. 另一个机会是将组件包装在View
标记中。
Here is the related issue with if checks: 这是if检查的相关问题:
https://github.com/facebook/react-native/issues/13653 https://github.com/facebook/react-native/issues/13653
In case you already solved it, please let us know how 如果您已经解决了,请告诉我们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.