flex with non flex wraper do not respect children size #1787
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello,
I've noticed discrepancy between yoga and web(chrome and safari tested) behaviour.
Its very easy to notice that on snack
https://snack.expo.dev/@matew/yoga-rendering-issue
Summary
To make it easier lets assume the following:
container
- is the first component with no height and flex setflex wrapper
- iscontainer
child which has flex set and border definedstatic component
- isflex wrapper
child which has static size (50x50)As you may notice on above screenshot for mobile devices
border
applied onflex wrapper
is just squeezed and overlaps withstatic component
In that situation yoga set that
flex wrapper
size to 0 while on webit respect that there is available space and
static component
has defined size.How web supports when there is no enough space?
I've created a snack which helps to illustrate how it works on web
https://snack.expo.dev/@matew/eager-yellow-tortilla
Screen shoot
Yoga/RN has documented behavior where
flex: 1
unlike web meansflexGrow: 1
,flexShrink: 1
. You will see same behavior if you set this in web.This is super weird behavior, that RN web does not try to emulate, but around forever.
UseWebDefaults
in Yoga IIRC changes this, but has its own wide set of problems, because it doesn't set everything to web defaults, because the flag was added before Yoga supported many of these defaults (not very forward looking...).Would recommend using
flexGrow
andflexShrink
explicitly.Thats interesting! 🤔
Thank you for explaining that! 🙏
I will open an issue inside react-native-web to clarify that discrepancy!