question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot add a child that doesn't have a YogaNode to a parent without a measure function!

See original GitHub issue

Cannot add a child that doesn't have a YogaNode to a parent without a measure function exception when Component co-existing in same parent as TextInput which triggers component removal.

Environment

Environment: OS: Linux 4.13 Node: 9.4.0 Yarn: 1.3.2 npm: 5.7.1 Watchman: 4.9.0 Xcode: N/A Android Studio: 3.1 AI-173.4670197

Packages: (wanted => installed) react: ^16.3.1 => 16.3.1 react-native: ^0.55.2 => 0.55.2

Steps to Reproduce

Simplified example: Change text in TextInput field https://snack.expo.io/SyAcWQFoz

Expected Behavior

<Text> component stops existing

Actual Behavior

Exception thrown:

Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'RCTRawText [text: ]' to a 'RCTView')
addChildAt
    ReactShadowNodeImpl.java:279
addChildAt
    ReactShadowNodeImpl.java:56
manageChildren
    UIImplementation.java:446
manageChildren
    UIManagerModule.java:416
invoke
    Method.java
invoke
    JavaMethodWrapper.java:372
invoke
    JavaModuleWrapper.java:160
run
    NativeRunnable.java
handleCallback
    Handler.java:751
dispatchMessage
    Handler.java:95
dispatchMessage
    MessageQueueThreadHandler.java:29
loop
    Looper.java:154
run
    MessageQueueThreadImpl.java:192
run
    Thread.java:761

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:30
  • Comments:63 (9 by maintainers)

github_iconTop GitHub Comments

193reactions
lebedevcommented, Apr 10, 2018

The issue is that you try to render an empty string outside a Text component:

{state.error &&
    <Text>
        Some text
    </Text>
}

If state.error is an empty string (falsey value), this transforms into {''}. And you can’t render an empty string ('') or zero (0) outside of Text component. But all other falsey values will do. Try to turn this into another falsey value.

For example (null):

{state.error
    ? (
        <Text>
            Some text
        </Text>
    )
    : null
}

or (false)

{!!state.error &&
    <Text>
        Some text
    </Text>
}
31reactions
lebedevcommented, May 31, 2018

By the way, I’ve just noticed, that this error message actually shows a text that caused it (notice Test text). image

Read more comments on GitHub >

github_iconTop Results From Across the Web

React native: Cannot add a child that doesn't have ...
React native: Cannot add a child that doesn't have a YogaNode or parent node - Stack Overflow. Stack Overflow for Teams – Start...
Read more >
React native: Cannot add a child that does not have a ...
React native: Cannot add a child that doesn't have a YogaNode or parent without a measure function. While working with react native ...
Read more >
Cannot add a child that doesn't have a YogaNode or pare…
Error Message : Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a...
Read more >
Error: Cannot add a child that doesn't have a YogaNode to ...
Error: Cannot add a child that doesn't have a YogaNode to a parent without a measure function! 野兽仙贝 关注. 2018.08.16 01:09:31 字数265.
Read more >
报错Cannot add a child that doesn't have a YogaNode to ...
遇到一个问题:ReacNative:报错Cannot add a child that doesn't have a YogaNode to a parent without a measure function!完美被这个解决:解决.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found