react-native: Flex wrap has bugs
flex style has some bug, just like the chat scene:

textContainer: {
flexDirection: 'row',
flexWrap: 'wrap',
},
textContent: {
color: '#333',
fontSize: 16,
},
url: {
color: '#007aff',
},
wrap is not ok.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 17 (3 by maintainers)
Commits related to this issue
- HAMO-16: Fix https://github.com/facebook/react-native/issues/8960 — committed to mboraski/HastyMobile by deleted user 7 years ago
- Hamo 16 (#5) * HAMO-16: Match mockup * HAMO-16: Add styling for selected filter * fix package.json * Use components from HAMO-8 and use em in stylesheets * Add missing tests and snapshots... — committed to mboraski/HastyMobile by deleted user 7 years ago
@jaynsw Have you tried using
alignItems: 'flex-start'?I’m not sure if this is the same issue @jaynsw is talking about but I see this with
flexDirection: 'row'andflexWrap: 'wrap':Adding
alignItems: 'flex-start'fixed it. I’ll need to study the reason why later…Thanks, @kulmajaba!
alignItems: 'flex-start'also works on my projectUsing version 0.34.1, it looks like
flexWrap: 'wrap'preventsalignItems: anyfrom working:results in:
flexWrap: 'nowrap'(or just commenting it out) results in:I’ve tried all the combinations of
flexDirection,flexWrapandalignItems. WhenflexWrap: 'wrap',alignItemshas no effect.Hi @chrbradley , I foo faced the same issue. I fixed it by wrapping the container
Viewby anotherViewand applied this style{flex:1,justifyContent:'center'}In your case it should be something like this,
Elements inside a
ViewwithflexDirection: 'wrap'andflexWrap: 'wrap'will behave as they should,Textelements will overflow to the right because of theflexDirection.A common solution to this is to wrap the
Textelement in a separateViewthat hasflexDirection: 'column'in the styles.Hope this helps.
alignItems: 'flex-start'Fixed the issue for me.@idibidiart What kind of an issue?
To recap the issues on this thread:
The original issue with text wrap inside a flex container
In a fresh React Native 0.44 project I could not reproduce this issue. Text will wrap in the following cases, all components inside a
Viewcontainer:Textis inside aView,ViewstylesflexDirectionandflexWrapcan be any combinationTextis standalone in the containerView,TextstylesflexDirectionandflexWrapcan be any combinationOriginally the workaround would have been to wrap the
Textcomponent in aViewwith styleflexDirection: 'column'. Now it seems this is not needed.Empty space in the bottom of
Viewcomponents inside a flex containerAgain, could not reproduce the issue in React Native 0.44, seems like this is fixed as well. Tested by placing a bunch of
Viewcomponents with stylesminHeight: 100, minWidth: 100inside a containerViewwith stylesflexDirection: 'row', flexWrap: 'wrap'. The boxes will take up minimum space.Taking out
flexWrapfrom the containerView, the boxes will fill vertical space as expected, because the default behavior foralignItemsis'stretch'and the primary flex direction has been set to'row'.Using
flexWrap: 'wrap'preventsalignItemsfrom workingThis is true, but it’s not an issue, it’s a feature and complies with the CSS3 reference.
alignItemsaligns the children components in the cross direction. However you are already defining how the children should be aligned in the cross direction by usingflexWrap.You need to usealignContentstyle instead as this will align the rows in the cross direction, not the children.@kulmajaba
thanks.
if I want to input emoji which is an image, the result is one image one row, it’s so ugly.