You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@bogdantmm92 - the problem is that it won't wrap because the flexDirection is row - it just continues flowing in that direction rather than downwards (as it would with column). I fixed this for you in this example on rnplay - thanks for providing an excellent sample! Makes the issue much easier to address
Reacted by rchee, Sergey Korochansky, Chad Wilken, Efkan, Shaun Befort, Ioannis Kokkinidis, Han Lynn, Joseph An, Shashank, Ambar Choudhury and 10 more
Reacted by Matthias Prieth, Ihor Kysylevych, Nicolás Pinochet, Michael Bruce Allen, Ben Baron and Elin
Reacted by Alexandre Correa
Reacted by Matt Hampel, Lorenzo Pieri and Nigel Baillie
Try add flexWrap: "wrap" to the style of the Text component
Reacted by Benjamin, hhphuc12, Pavle Andric, Joseph Lloyd, psyanite, Ashkon, nanosoft-vivek, Daniel Fernando Lourusso, Nikhil Parmar, Alexandre Correa and 5 more
Reacted by Matthias Prieth, xahon, Andrei Savchuk, 姚泽源, Nick Malezh, trigkit4, Anderson Fernandes da Silva, Ivan Vynnyk, Jérémy M, s_Beez and 16 more
Reacted by Joseph Lloyd, psyanite, sfm2222 and museong
Reacted by Pavle Andric, Joseph Lloyd, jhon-erick, Nikhil Parmar, Alexandre Correa, raghib and Nigel Baillie
Reacted by sfm2222, Vlad Svidrickiy, Imran Khan, raghib, Aditya, webbin and Kamil Sarna
Reacted by Joseph Lloyd, Antonio Grass, psyanite, jhon-erick, Lucas Amador and raghib
Hey there @mvnnn, I was able to get this to work by adding a 'flex: 1' property to the text element. Hopefully it works in your situation, as well.
<View style={{flexDirection:'row'}}> <Text style={{flex: 1, flexWrap: 'wrap'}}> You miss fdddddd dddddddd You miss fdddddd dddddddd</Text> </View>
Reacted by James McCarthy, Michael Radionov, David Sheldrick, PanpanHan, Kyle Alwyn, Filip Jarno, Andrew Chen, Akos Krivachy, septemptus, Orr Bibring and 77 more
Reacted by webbin and Nico Castro
Reacted by Aline Francois, Preeti Wadhwani, Cesar Millan, Brandon Trautmann, Yaron Levi, Jon Green, Alex Buicescu, William Candillon, Ahmet AYDOĞDU, wswoodruff and 18 more
Reacted by Arsal Abdullah, Fausto Torres, Aaron Brager, M3po, Yin Shangwei, Greg Westneat, Tan Nguyen, IntraMuros, hyungtae, Jacob Devera and 3 more
<View style={{flexDirection:'row', flex: 1, flexWrap: 'wrap'}}> <Text> You miss fdddddd dddddddd You miss fdddddd dddddddd</Text> </View>
Reacted by Lucas Bento, Fausto Torres, vonZ, Tan Nguyen, Jan Peer Stöcklmair, Alexander Veligurov, Peter Thanakrit Weekhamchai, Freya Yu and Mohammed Taher
Reacted by Jan Peer Stöcklmair and Alexander Veligurov
Reacted by Lucas Bento, Fausto Torres, Jan Peer Stöcklmair and Alexander Veligurov
I tried @a11y1337 's method and it didn't work for me. I have a situation where I have text sitting in a View along side of another View and the text is running through the parent's padding and out of the parent's container:
As I said, I tried all of the the suggestions here and nothing seemed to work. WHAT DID WORK was adding a width: 0 to the info style:
info: {width: 0,flexGrow: 1,marginLeft: gutter,},
and voilà:
Reacted by Aman Agarwal, Ari Litan, Diego Allen, YoranRoels, Andrew Henderson, Grigory Ptashko, Abhilash Singh, dnish, Sébastien Lorber, valentino and 33 more
Reacted by Apurva Jain, Adam Pietrasiak, Hesham Yassin, Dimitry and Lorenzo Pieri
Reacted by George Mickael Antony, Amal Chandran, Jesper Lekland, Chris Jungmann, Koen Punt, Mads Jensen, Yoan Pratama Putra, Abe Clark, Tiger.G, YoranRoels and 26 more
Reacted by Duan, Alexandre Correa, Ozgur, Matt Hampel, mai danh and Ganapathy S
After a bit of hard time I've found out that adding flexShrink: 1 to text container helped.
Reacted by Prerak Dholakiya, Majd, Ricardo Fuhrmann, Filipe Araujo, Roberto Frenna, Pavel Baskakov, Binur Konarbai, Yordis Prieto, David Martin, Bright Lee and 17 more
Reacted by bd, Yogesh Kumar, Yusuf Musleh, Yara Kanigara and James Adams
Reacted by Ricardo Fuhrmann, Binur Konarbai, Yordis Prieto, Yoann Bentz, bd, Yogesh Kumar, Dan Hassin, Muhammad Arsal Abdullah, Yusuf Musleh, Lorenzo Pieri and 2 more
Reacted by Ricardo Fuhrmann, Binur Konarbai, Yordis Prieto, Yoann Bentz, Syed Haani Hasan, Juraj Krivda, bd, Yogesh Kumar, Muhammad Arsal Abdullah, Yusuf Musleh and 4 more
So far @gusgard answer always worked for me but I just faced this issue and despite all of the documented solution no one actually worked except for that one :
All of the above solutions didn't work for me, I had a fairly complicated view hierarchy, simpler versions always worked as expected.
Also, I was using react-native-web, so coding to react-native standards, using View and Text components as the basis for all rendering. The above did allow me to resolve the issue on Native, but it didn't resolve it on Web.
The correct solution (for me) was to ensure that I had flex: 1 on ALL ancestors of the Text node that was not wrapping as expected.
So - check your view hierarchy, you can do this in the browser using the Element Inspector (Computed Styles), just walk up from the non-wrapping node and check for display: flex - anything missing flex is missing the corresponding flex: 1.
NB: Text nodes in react-native-web do not pass the flex property to the underlying div/span.
<View style={style.textWrap}>
<Text numberOfLines={your value} >
Your very very very very very long text content
</Text>
</View>
style ={
textWrap:{
width: your_certain_width
}
}
Activity
brentvatne commentedon May 28, 2015
@bogdantmm92 - can you post a complete minimal example on rnplay.org please?
[-]Text doesn't wrap [/-][+][Text] Text doesn't wrap [/+]bogdantmm92 commentedon May 28, 2015
Demo: https://rnplay.org/plays/21GRFQ
brentvatne commentedon May 28, 2015
@bogdantmm92 - the problem is that it won't wrap because the
flexDirectionis row - it just continues flowing in that direction rather than downwards (as it would with column). I fixed this for you in this example on rnplay - thanks for providing an excellent sample! Makes the issue much easier to addressbogdantmm92 commentedon May 28, 2015
Thanks for testing & fixing this so fast! Really appreciate it!
uc-hus commentedon Jul 29, 2016
How to break text of flexDirection: row view

peter4k commentedon Aug 5, 2016
Try add
flexWrap: "wrap"to the style of the Text componentmvnnn commentedon Sep 8, 2016
@peter4k That's not works in my case.
peter4k commentedon Sep 9, 2016
@mvnnn You have to add it to your component, like:
mvnnn commentedon Sep 10, 2016
@peter4k thanks, I also try this but that's not working inside
cardso i use "minWidth" and "maxWidth" and that's working great.a11y1337 commentedon Sep 13, 2016
Hey there @mvnnn, I was able to get this to work by adding a 'flex: 1' property to the text element. Hopefully it works in your situation, as well.
<View style={{flexDirection:'row'}}> <Text style={{flex: 1, flexWrap: 'wrap'}}> You miss fdddddd dddddddd You miss fdddddd dddddddd</Text> </View>janaka120 commentedon Dec 20, 2016
I think this also work
<View style={{flexDirection:'row', flex: 1, flexWrap: 'wrap'}}> <Text> You miss fdddddd dddddddd You miss fdddddd dddddddd</Text> </View>dwilt commentedon Feb 9, 2017
I tried @a11y1337 's method and it didn't work for me. I have a situation where I have text sitting in a
Viewalong side of anotherViewand the text is running through the parent'spaddingand out of the parent's container:Markup:
Styles:
As I said, I tried all of the the suggestions here and nothing seemed to work. WHAT DID WORK was adding a
width: 0to theinfostyle:and voilà:
georgemickael-b commentedon Feb 17, 2017
@dwilt That helped!
5 remaining items
Fixed bug in iOs
pavloko commentedon May 27, 2017
Hi all,
Text supports
NumberOfLinesproperty, not sure about the case described above, but maybe it can be an option.gusgard commentedon Jun 6, 2017
@dabit1 thanks!
Example that works:
Code
Styles
pie6k commentedon Oct 13, 2017
After a bit of hard time I've found out that adding
flexShrink: 1to text container helped.mehdialouafi commentedon Dec 5, 2017
So far @gusgard answer always worked for me but I just faced this issue and despite all of the documented solution no one actually worked except for that one :
I found this gem https://stackoverflow.com/questions/38233789/react-native-view-auto-width-by-text-inside. the accepted answer tells us that 👍
I don't know you but I really didn't know. Just tested it and it worked like a charm.
yordis commentedon Dec 14, 2017
@pie6k solution is the best subjectively approach but put it on the
Textthat you want to wrap.benevbright commentedon Dec 23, 2017
@pie6k You saved my day. Many thanks for your sharing!
charleylla commentedon Dec 27, 2017
this worked for me:
nanosoft-vivek commentedon Jan 25, 2018
dmeehan1968 commentedon Feb 4, 2018
All of the above solutions didn't work for me, I had a fairly complicated view hierarchy, simpler versions always worked as expected.
Also, I was using
react-native-web, so coding toreact-nativestandards, usingViewandTextcomponents as the basis for all rendering. The above did allow me to resolve the issue on Native, but it didn't resolve it on Web.The correct solution (for me) was to ensure that I had
flex: 1on ALL ancestors of theTextnode that was not wrapping as expected.So - check your view hierarchy, you can do this in the browser using the Element Inspector (Computed Styles), just walk up from the non-wrapping node and check for
display: flex- anything missingflexis missing the correspondingflex: 1.NB:
Textnodes inreact-native-webdo not pass theflexproperty to the underlyingdiv/span.mehdialouafi commentedon Feb 6, 2018
@dmeehan1968 your solution solved this problem on one occasion thank you !
There are a lot of solutions to this problem
Fix incorrect wrapping in TermsAndConditionsScreen
Fi2zz commentedon May 24, 2018