react-native-web: StyleSheet: word-break property to wrap long continuous strings
Do you want to request a feature or report a bug?
Both.
What is the current behavior?
I have a very long string that I need to wrap to multiple lines, but it looks like this CSS property is not supported (word-break: all
?).
When this component is rendered on native, the text wraps as desired:
When rendered on web, the text will not wrap to multiple lines, which causes the component to break out of the layout and create scrollbars.
Demo: https://cheddur-rgsymrxmda.now.sh/story/7NcMectnqEW4QivYj -> the cryptocurrency address.
If you shrink your viewport, you see:
- Browser: all
- React Native for Web (version): 0.1.16
- React (version): 16.2.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 16 (5 by maintainers)
Or you can simply add
{ wordBreak: "break-word" }
to theView
style.to replicate the issue put this component in render
<Text>ldjahflkasdjhflakshjflaksjhdflakshdjflaksjhdfalksjdhflaskdfhjlaskdfjhaslkdfhjlaskjdfhlaskjhdfajsdhflaksjdhflaskdfhalskdfhj</Text>
This issue should be reopen. There should be a way to specify
word-break: break-word
on the web platform. That’s the only way to force long words to be broken on the web. (Unless you know a better cross-browser-platform way to do it, I’m happy to learn.flex-shrink
won’t do it).Currently our workaround is a bit troublesome and goes like this:
<style>
to our index.html with the following:ref
andsetNativeProps
add the[word-break="break-word"]
attribute to the element like this:@necolas it appears a single long string that doesn’t have spaces causes this issue.
I’m just asking for someone to provide a reduced test case on codesandbox, as is mentioned as being required in the issue template. Help me to help you.
What’s an example of code that produces the issue?