-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Cannot add a child that doesn't have a YogaNode to a parent without a measure function! #18773
Comments
Same problem! |
For now I just display empty text instead of removing |
The issue is that you try to render an empty string outside a
If For example (
or (
|
Also seeing this issue. Causing major issues on the app after upgrading. Seems to be largely for Android. |
Same here, with the added problem that the error/stacktrace doesn't show which files of my project contain the issue making it very hard to fix :/ |
I have this issue as well, only on Android. And I couldn't find any problem with my TEXT!! |
We're having the same problem here too :( and no way of easily seeing which file is causing it |
I had a semi colon somewhere it shouldn't have been. |
I have same problem too. Over one day =.= |
I've had the same problem for a while until I realized that in order to make a line break between 2 paragraphs, I had this {`\n`} between 2 Text components. Removing it fixed this issue for me |
Same here. Fixed by removing texts that was outside the |
Issue was fixed for me by removing a space I had between my tags. |
on android, do not use { your_condtion && <YourComponent/ >} |
I had this issue when I had an unnecessary semi-colon on my function call inside my render function.
|
Yeah, echoing what @kaueDM said, has anyone figured out a nifty way to trace back to this error? I've been a bad dev and used this pattern a few times :/ |
@angly-cat solution solved my problem, just put a !! at my short circuit evaluation.
|
Just reiterating and providing an attempt to explain what is happening. Using a double bang (!!) will coerce the condition into a boolean. In some cases the conditional might be falsy, but evaluates to a non-boolean value (i.e. 0). React then tries render this non-boolean value, which is no longer acceptable in Android with current versions of react-native. Its worth considering avoiding using the && operator for conditional rendering if you are not going to be using booleans as your conditional. |
Rendering |
@jamiesonbates yes, In my case this was caused by |
In my case, it was something like
Worked on iOS but crashed on Android with similar error message ('RCTRawText [text: >]') |
Can someone explain what is actually causing the problem? |
It appears to be an issue with 'falsey' strings/numbers/undefined breaking rendering. So specifically a You can workaround this by using |
Ran into the same issue where my app worked in debug mode but upon production it crashed with the same set of errors. I had extended the |
I was able to solve this by changing |
I solve this problem for me
just because the ',' delete it, it works |
Does anyone use tooling to help prevent these? Lint/regex/other static analysis? |
I have found solution for this issue. refer this link : https://www.skptricks.com/2018/08/react-native-cannot-add-child-that.html |
This error also occurs if you have comments in your render() return() function. Remove all comments in your return function when rendering JSX |
I am not sure this might be helpful or not. I also was having this same issue and couldn't find out the reason causing the problem. As it turns out, I forgot to add static navigationOptions in my class component. Like : |
Worked for me after I removed a > that was extra in my code |
This is fairly frustrating and time-consuming behavior, especially when porting a large iOS project to Android. As has been noted, the generic error occurs when there is an extra space in your single-line JSX, such as It would be great if spaces in single-line JSX could be allowed. More importantly probably would be a line number or at least a file in which the problem occurred . I also opened an issue to catch this in TSLint (palantir/tslint-react#188). Not sure if it is a rule option in ESlint |
Hi, I had the exact same error yesterday (fixed this by reading the thread and changing Now, as @vjsingh said, this is a very frustrating issue, and even though a rule in tslint would be nice, I think the main issue here is that this error message isn't giving any information but the string used (and in my case the string was empty, so I had absolutely no idea where the error was, and in fact it happened after I changed SQLite lines and thought for hours that I was doing something wrong with my SQL requests) Is there any hint of how this message could be improved? Just giving the file and the line would be an awesome win for my work time :') I'd love to take a look at this issue but I don't know what I could do |
Implementation should be error-tolerant because it's easy to make a mistake. Logic is implemented here #22776. |
Thanks for that update @rostislav-simonik 👍 In an effort to reduce the number of open issues and this issue having a open PR to fix it, I’ll close this for now. If somebody verifies the PR and it turns out to not actually address this issue, please let us know and we can re-open. |
This solved my issue. :) |
A lot if not all of these issues will be caught with the |
That's a good news! But how can this be communicated so devs actually knows about that eslint rule that could help them? Documenting it like in an FAQ? |
use "xx? xx : ' ';"instead of "xx&&xx" |
Shouldn’t |
same issue in android |
Hi all! Sorry for the long wait but I think the fix for this just landed. We were able to repro and fix this issue with this sample code:
|
cannot add a child that doesn't have a yoganode to a parent without a measure function in expo |
Cannot add a child that doesn't have a YogaNode to a parent without a measure function
exception whenComponent
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 existingActual Behavior
Exception thrown:
The text was updated successfully, but these errors were encountered: