Javascript 反应自然';无法添加不包含';如果没有测量功能,就不能向父级发送数据';

Javascript 反应自然';无法添加不包含';如果没有测量功能,就不能向父级发送数据';,javascript,react-native,components,Javascript,React Native,Components,App.js呈现可重用的外部组件及其子组件。当在其渲染函数中使用{this.state.visible?children:null}确认子对象时,将执行淡入淡出中的动画。调试后,我相信错误是由三元运算符引起的,这是由于在Fade的渲染函数中定义了三元运算符 我的问题是,我不知道如何在渲染中正确包装这个三元操作符。我尝试了和,但没有成功。有人知道如何解决这个问题吗 先谢谢你 App.js渲染 <Container> <Fade visible={display.bus}>

App.js呈现可重用的外部组件及其子组件。当在其渲染函数中使用
{this.state.visible?children:null}
确认子对象时,将执行
淡入淡出
中的动画。调试后,我相信错误是由三元运算符引起的,这是由于在
Fade
的渲染函数中定义了三元运算符

我的问题是,我不知道如何在渲染中正确包装这个三元操作符。我尝试了
,但没有成功。有人知道如何解决这个问题吗

先谢谢你

App.js渲染

<Container>
  <Fade visible={display.bus}> {renderIf(display.bus, <BusTemplate />)} </ Fade>
</Container>
<Animated.View style={this.state.visible ? combinedStyle : containerStyle}>
  {this.state.visible ? children : null}
</Animated.View>
<Container>
  <Image source={require("./scenerios/Bus.png")} style={styles.MainContainer}>
  </Image>
</Container>

{renderIf(display.bus,)}
Fade.js渲染

<Container>
  <Fade visible={display.bus}> {renderIf(display.bus, <BusTemplate />)} </ Fade>
</Container>
<Animated.View style={this.state.visible ? combinedStyle : containerStyle}>
  {this.state.visible ? children : null}
</Animated.View>
<Container>
  <Image source={require("./scenerios/Bus.png")} style={styles.MainContainer}>
  </Image>
</Container>

{this.state.visible?子项:null}
Bus.js渲染

<Container>
  <Fade visible={display.bus}> {renderIf(display.bus, <BusTemplate />)} </ Fade>
</Container>
<Animated.View style={this.state.visible ? combinedStyle : containerStyle}>
  {this.state.visible ? children : null}
</Animated.View>
<Container>
  <Image source={require("./scenerios/Bus.png")} style={styles.MainContainer}>
  </Image>
</Container>

再见,迭戈, 一旦我读到这个问题与
if
有关,请检查
未定义的
变量。可能是您的
this.state.visible

另一种方法是将组件包装在
视图
标记中。
以下是if检查的相关问题:


如果您已经解决了问题,请告诉我们如何解决

谢谢您的回复。我需要检查一下,然后告诉你结果。