作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
App.js 呈现可重用的外部组件 Fade
及其子组件。 Fade
中的动画当使用 {this.state.visible ? children : null}
确认 child 时执行在它的渲染函数中。调试后,我认为错误是由三元运算符引起的,因为它在 Fade
的渲染函数中定义的方式。 .
我的问题是我不知道如何在渲染中正确包装这个三元运算符。我试过<Text>
和 <View>
没有成功。有谁知道如何解决这个问题?
提前谢谢你。
App.js 渲染
<Container>
<Fade visible={display.bus}> {renderIf(display.bus, <BusTemplate />)} </ Fade>
</Container>
Fade.js 渲染
<Animated.View style={this.state.visible ? combinedStyle : containerStyle}>
{this.state.visible ? children : null}
</Animated.View>
Bus.js 渲染
<Container>
<Image source={require("./scenerios/Bus.png")} style={styles.MainContainer}>
</Image>
</Container>
最佳答案
再见迭戈,一旦我读到这个问题与 if
检查 undefined
变量有关。 this.state.visible
可能是您的情况。
另一种方法是将您的组件包装在 View
标记中。
这是 if 检查的相关问题:
https://github.com/facebook/react-native/issues/13653
如果您已经解决了,请告诉我们如何解决
关于javascript - React-Native 'Cannot add a child that doesn' t 有一个 YogaNode 到没有测量功能的 parent !,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48565250/
我是一名优秀的程序员,十分优秀!