Let's say I have the following react-native code:
//FormatText.js
<View style={styleOptions.container}>
<Text style={styleOptions.regular}>
Hello world I am going to eat some Pizza for the sake of eating pizza.{" "}
</Text>
<Text style={[{ fontWeight: "bold" }, styleOptions.strong]}>
Super Pizza Store.{" "}
</Text>
<Text style={styleOptions.regular}>You will pay $10</Text>
<Text style={[{ textAlignVertical: "top" }, styleOptions.superscript]}>
8
</Text>
<Text style={styleOptions.regular}>. I doubt you can afford it.</Text>
</View>;
And the styleOptions
is defined in this file.
//Style.js
const styleOptions = {
container: {
flexDirection: "row",
flexWrap: "wrap",
width: 300,
padding: 10
},
regular: { fontSize: 13 },
superscript: { fontSize: 8 },
strong: { fontSize: 13 }
};
I see the following output:
The problem is that there is a line break after "Super Pizza Store" and after the exponent. I'd imagine that's because each Text component is too long to fit in the space of 300px.
How do I get rid of line breaks and only allow for natural line breaks? Ideally, I want to limit my changes to Style.js
only. As a last resort, if absolutely necessary, I will restructure the contents of FormatText.js
.