简体   繁体   English

React-Native“如果没有测量功能,则无法将没有YogaNode的孩子添加到父母中!”

[英]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.

相关问题 React Native,如果没有测量功能,则无法将没有YogaNode的子代添加到父代 - React Native, Cannot add a child that doesn't have a YogaNode to a parent without a measure function React native:无法添加没有YogaNode的子项或没有measure函数的父项 - React native: Cannot add a child that doesn't have a YogaNode or parent without a measure function 无法将没有 YogaNode 的孩子添加到没有测量功能的父级! (尝试将“ReactRawTextShadowNode”添加到“LayoutShadow - Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'ReactRawTextShadowNode' to a 'LayoutShadow 如果没有measure函数,则无法将没有YogaNode的子节点添加到父节点 - Cannot add a child node that doesn't have a YogaNode to a parent without measure function 没有测量功能,无法将具有YogaNode的孩子添加到父母 - Cannot add a child that doenst have a YogaNode to a parent without a measure function 无法将没有 YogaNode 的孩子添加到父母 - Cannot add a child that doesn't have a YogaNode to parent 无法将没有Yoganode的孩子添加到父母 - cannot add a child that doesn't have a yoganode to a parent 无法添加没有YogaNode的孩子 - Cannot add a child that doesn't have a YogaNode 无法添加没有YogaNode的孩子-SVG和动画 - cannot add a child that doesn't have a YogaNode - SVG and Animated 如何从孩子呼叫父母 function - react-native - How to call a parent function from a child - react-native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM