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.

Bug: inner view with `flex: 1` collapses its size to 0

See original GitHub issue

Describe the bug

When flex: 1 is added to an inner view inside the carousel, its size will be collapsed to 0.

To Reproduce

Repro in https://github.com/dohooo/react-native-reanimated-carousel/pull/211

Expected behavior

Size should not collapse, or docs should reflect to not use flex: 1.

Screenshots

With flex: 1:

Simulator Screen Shot - iPhone 13 - 2022-06-25 at 11 57 14

Without flex: 1: Simulator Screen Shot - iPhone 13 - 2022-06-25 at 11 57 24

Versions (please complete the following information): This bug is visible in current master. See repro in #211

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oliverloopscommented, Jul 16, 2022

Using the same layout implementation and works fine. flex: 1 instead flexGrow:1 works fine. but this is a related behavior with the element inside and not the Carousel itself and can be solved modifying the display attribute of the item container.

0reactions
dohooocommented, Oct 18, 2022

Hey @oliverloops, could you expand on your answer above?

I have a component that I use both inside and outside of a react-native-reanimated-carousel. When it’s inside the carousel, the text gets collapsed as described in this ticket. When outside the component, it works fine.

I tried Toastbroad’s solution of changing flex: 1 to flexGrow: 1, and that fixed it inside the carousel. But then the component outside the carousel grows way too large.

I think you are on to something with recommending that we change the display attribute. But could you elaborate a bit more? According to the react-native docs, the default for display is “flex”, which is what I want. I don’t see any change in behavior when I explicitly set display: flex in the containing View. What did you have in mind when you susgested this solution?

Thanks for your help!

Could you provide a minimal reproduction?

Read more comments on GitHub >

github_iconTop Results From Across the Web

When flexbox items wrap in column mode, container does not ...
Just a sidenote, but there's a bug in Chrome that causes a container with it's flow set to column wrap not to expand...
Read more >
`flex: 0` does not respect intrinsic size on Web; but ... - GitHub
When flex is -1, the component is normally sized according to width and height . However, if there's not enough space, the component...
Read more >
Flex-basis not respected when intrinsically sizing nested flex ...
What happens in Firefox currently is ".horizontal-container-shrink" is behaving as if it has flex: 1 1 auto; forcing its parent ".horizontal-container > li: ......
Read more >
`flex-grow` is weird. Or is it? | CSS-Tricks
If the width of each element is 0, the remaining space equals the actual width of the parent element and thus it looks...
Read more >
Collapse - Bootstrap
Collapsing an element will animate the height from it's current value to 0 . Given how CSS handles animations, you cannot use padding...
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