gpt4 book ai didi

javascript - 无法将没有 YogaNode 的 child 添加到没有测量功能的 parent ! (试图将 'ReactRawTextShadowNode' 添加到 'LayoutShadow

转载 作者:数据小太阳 更新时间:2023-10-29 04:54:17 30 4
gpt4 key购买 nike

根据this教程,这是我用于 react base 组件作为侧边栏组件的组件,它工作得很好,但是当我从 <Text> 更改列表项时问题就开始了至 <Button>

    import { Text, Container, Header, Content, List, ListItem, TextBody, Button } from 'native-base';
import { StackNavigator, DrawerNavigator } from 'react-navigation'

export default class SideBar extends Component {

render() {
return (
<Content style={{ backgroundColor: '#ffffff' }}>
<Container>

<Content>
<List>
<ListItem>
<Text>First</Text>
</ListItem>
<ListItem>
<Text>Secount</Text>
</ListItem>
<ListItem>
<Text>Third</Text>
</ListItem>
</List>
</Content>
</Container>
</Content>
);
}
}

我收到这个错误:

cant add a child that doesn't have a YogaNede to parent without the measure function !(Trying to Add a 'ReactRawTextshadow' to a 'LayoutShadowNode' )

根本无法理解这个错误,也没有在网上看到任何关于它的信息!

> Cannot add a child that doesn't have a YogaNode to a parent without a
> measure function! (Trying to add a 'ReactRawTextShadowNode' to a
> 'LayoutShadowNode') addChildAt
> ReactShadowNodeImpl.java:199 addChildAt
> ReactShadowNodeImpl.java:54 setChildren
> UIImplementation.java:472 setChildren
> UIManagerModule.java:436 invoke
> Method.java invoke
> Method.java:372 invoke
> JavaMethodWrapper.java:374 invoke
> JavaModuleWrapper.java:162 run
> NativeRunnable.java handleCallback
> Handler.java:739 dispatchMessage
> Handler.java:95 dispatchMessage
> MessageQueueThreadHandler.java:31 loop
> Looper.java:135 run
> MessageQueueThreadImpl.java:194 run
> Thread.java:818

最佳答案

对于由于与 OP 相同的错误消息而登陆此页面的其他人,有很多问题会导致相同的错误消息。
有一个 GitHub issue围绕此一般错误消息。

可能最常见的原因是:

  • 要呈现的文本未包含在 <Text> 标签
  • JSX 中的语法错误(例如 ; 或格式错误的标记)
  • 如果您使用 Prettier,则在 JSX 注释和 JSX 标记之间留一个空格
    (看起来 Prettier 自动插入了一个 ;
    (解决方案:将 JSX 注释移到它自己的行)

  • 一些值假定为 null , 但它是 undefined ,或 '' (空字符串)。
    '' 的情况下, 它需要包裹在 <Text> 中(看上面第一项)

  • 不包装子标签 ( ScrollView in particular )
  • space between two adjacent tags
  • CSS 的问题

    If a CSS node has measure defined, the layout algorithm will not visit its children. Even more, it asserts that you don't add children to nodes with measure functions.

如果您无法找到错误的根源,我强烈建议您看一看:<强> https://github.com/facebook/react-native/issues/13243

作为一个人wrote :

To summarize:
This issue is about what React Native perceives to be mal formatted JSX (usually occurring on Android render) and this thread has done a good job documenting the many forms this malformatted JSX can come in.

It Still doesn't solve the need for developers to comb through their code line by line looking for a random semicolons or spaces.

If there is a way to have the stack trace be more specific about the specific offending character or error, that would probably save devs hours of sad debugging..

关于javascript - 无法将没有 YogaNode 的 child 添加到没有测量功能的 parent ! (试图将 'ReactRawTextShadowNode' 添加到 'LayoutShadow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47627231/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com