Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native - hyphenation

I'm working on a React Native app where I show some text inside boxes. Sometimes the individual words in the boxes are too long to fit on one line so RN just breaks the word off when it would get too long and continues the text on the next line. This unfortunately leads to poor hyphenation of the words (see the left box in the image). I'm trying to find a solution to improve this such that in this example the result would be like the box on the right where the word is hyphenated at a reasonable point. I know there are javascript libraries that deal with hyphenation. This for examples breaks words into their hyphens in an array. I'm stuck here because I have no idea how to actually figure out if I need to hyphenate the word or not. Any ideas?

Poor hyphenation on the left, better on the right

like image 640
user3346601 Avatar asked Oct 19 '22 10:10

user3346601


1 Answers

use C/C++/Java Encoding:

text = 'React\u00ADNative'
<Text>{text}</Text>
like image 184
peni4142 Avatar answered Oct 21 '22 05:10

peni4142