Skip to content
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

Invalid layout for (1)<RCTRootContentView: 0x7bb9e0c0; reactTag: 1; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x7bb72450>; layer = <CALayer: 0x7bb783d0>>. position: {nan, nan}. bounds: {{0, 0}, {nan, nan}} #3406

Closed
nfranzmeier opened this issue Oct 14, 2015 · 12 comments
Labels
Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot.

Comments

@nfranzmeier
Copy link

On the latest releases 0.12.0 (also 0.11.4) - When compiling for iphone 4 or 5 (simulator) I get this error when trying to merge the baseline application - the one that is created by react-native init - into an an existing project.

For some reason it works when building for iphone6....

015-10-14 07:52:03.949 [error][tid:main][UIView+React.m:77] Invalid layout for (1)<RCTRootContentView: 0x7bb9e0c0; reactTag: 1; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x7bb72450>; layer = <CALayer: 0x7bb783d0>>. position: {nan, nan}. bounds: {{0, 0}, {nan, nan}}

I tracked this down to this function in RCTUtils.m

CGFloat RCTRoundPixelValue(CGFloat value)
{
CGFloat scale = RCTScreenScale();
return round(value * scale) / scale;
}

Apparently using round() which is for the type double, is the problem.

So, I changed it to roundf() which works with CGFloat and now it all works!

CGFloat RCTRoundPixelValue(CGFloat value)
{
CGFloat scale = RCTScreenScale();
CGFloat res = roundf(value * scale) / scale;
//NSLog(@"Result=%d",res); // NVF Fixed all rounds to roundf() so it computes right!!!!
return res;
}

In my codebase I searched for all other round() instances using float similarly and changed them also to use roundf()

All works consistently now.

Please fix this in the baseline -

@jaygarcia
Copy link
Contributor

I've been getting this since 0.11.0 :(.

@ide
Copy link
Contributor

ide commented Oct 15, 2015

@nfranzmeier @jaygarcia Can you submit a PR?

@nfranzmeier
Copy link
Author

If my comment/code change helped and you know how to submit a PR, it might be better as I'm unsure of the process...

@ide ide added the Help Wanted :octocat: Issues ideal for external contributors. label Oct 16, 2015
@mkonicek
Copy link
Contributor

Hi there! This issue is being closed because it has been inactive for a while.

But don't worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/-invalid-layout-for-1rctrootcontentview-0x7bb9e0c0-reacttag-1-frame-0-0-414-736-gesturerecognizers-nsarray-0x7bb72450-layer-calayer-0x7bb783d0-position-nan-nan-bounds-0-0-nan-nan

ProductPains helps the community prioritize the most important issues thanks to its voting feature.
It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix.
We're a small team and rely on the community for bug fixes of issues that don't affect fb apps.

@aymericbouzy
Copy link

aymericbouzy commented Jan 19, 2017

I got this error :

Invalid layout for (2486)<RCTView: 0x7fb5b8f19920; reactTag: 2486; frame = (6 0; 38 38); layer = <CALayer: 0x608000624000>>. position: {25, nan}. bounds: {{0, 0}, {4, nan}}

it seems related to this issue. Can someone submit a PR? I've never written any Objective-C code.
In my case, it didn't occur before RN 0.37, but now I have moved to RN 0.39, it happens all the time. I can give a repro.

@matthewjamieson
Copy link

+1

@JeroenNelen
Copy link

any news or update on this? I'm getting a similar issue:
Invalid layout for (879)<RCTView: 0x...

Kind regards,

@damathryx
Copy link

@JeroenNelen setting flex to null is what causing this error in my case. changed it to 0 fixed it for me.

@aymericbouzy
Copy link

Adding flex: 0 fixes it for me! I'm not setting flex to null though, so I'm not sure what was causing this in the first place ... I still think this issue should be reopened.

@fxrhxn
Copy link

fxrhxn commented Mar 27, 2017

Tried setting flex to 0 but still got the same error. It got resolved for me by setting flex to 1.

@mitogh
Copy link

mitogh commented Apr 4, 2017

I was experience a similar situation where I was adding a dynamic class that has flex: 1 after I removed that class the error was generated so I set flex: 0 on my initial class and that fixed the problem.

Thank you @damathryx @aymericbouzy

@JoeyCurry
Copy link

flex:0 fixed my problem
thanks @damathryx

@facebook facebook locked as resolved and limited conversation to collaborators Jul 21, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Help Wanted :octocat: Issues ideal for external contributors. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests