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.

Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'ReactVirtualTextShadowNode' to a 'NativeViewWrapper')

See original GitHub issue

I add code below to use yoga-node,but got an error,what‘s wrong?

@Override
        protected UIImplementationProvider getUIImplementationProvider() {
            return new FlatUIImplementationProvider();
        }
"react-native": "0.43.3"
java.lang.RuntimeException: Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'ReactVirtualTextShadowNode' to a 'NativeViewWrapper')
                                                                   at com.facebook.react.uimanager.ReactShadowNode.addChildAt(ReactShadowNode.java:173)
                                                                   at com.facebook.react.flat.FlatShadowNode.addChildAt(FlatShadowNode.java:217)
                                                                   at com.facebook.react.flat.NativeViewWrapper.addChildAt(NativeViewWrapper.java:98)
                                                                   at com.facebook.react.flat.FlatUIImplementation.addChildAt(FlatUIImplementation.java:510)
                                                                   at com.facebook.react.flat.FlatUIImplementation.setChildren(FlatUIImplementation.java:190)
                                                                   at com.facebook.react.uimanager.UIManagerModule.setChildren(UIManagerModule.java:326)
                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                   at com.facebook.react.bridge.BaseJavaModule$JavaMethod.invoke(BaseJavaModule.java:345)
                                                                   at com.facebook.react.cxxbridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:141)
                                                                   at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                                   at android.os.Handler.handleCallback(Handler.java:739)
                                                                   at android.os.Handler.dispatchMessage(Handler.java:95)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

25reactions
JCMaiscommented, Dec 26, 2017

This happens if you have space like mentioned above, or if you have conditional rendering, that is checking a non boolean variable, that can be undefined or an empty string. Example:

{myCheck && <MyComp />}

This returns an error if myCheck is undefined, or an empty string, because if its a falsy value, it’s going to be the value returned in the expression, and so, React will try to render it, but React cannot render undefined or empty string values inside non-Text elements, throwing the error above.

The solution is to cast the variable to a boolean:

{!!myCheck && <MyComp />}

Since false is correctly ignored on JSX.

11reactions
sebirdmancommented, Dec 21, 2017

This seems to be a problem with something that parses what your component returns from render().

in my case i had the following code:

<View>
  {someThing};
</View>

and the fix was removing the semicolon:

<View>
  {someThing}
</View>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot add a child that doesn't have a YogaNode to a ...
I am using the latest React Native version. Cannot add a child that doesn't have a YogaNode to a parent without a measure...
Read more >
React native: Cannot add a child that doesn't have a ...
Now if I try to run the code by adding flexdemo.js code into App.js then everything works fine. Changed The App.js like this:...
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 to a parent ...
Coding example for the question Cannot add a child that doesn't have a YogaNode to a parent without measure node-React Native.
Read more >
Cannot add a child that doesn't have a YogaNode to a ... - 简书
Cannot add a child that doesn't have a YogaNode to a parent without a measure function! (Trying to add a 'ReactRawTextShadowNode' to a ......
Read more >

github_iconTop Related Medium Post

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