Like this: <Text> Math inequality: 3 < 2x </Text>
How do I escape such characters so that JSX doesn't think it's a part of the component syntax?
TextInput is a Core Component that allows the user to enter text. It has an onChangeText prop that takes a function to be called every time the text changed, and an onSubmitEditing prop that takes a function to be called when the text is submitted.
After some testing, I found out that @stackdave's answer does not work. I don't know if it works on other versions of RN, but on [email protected], I got the following error: Cannot add a child that doesn't have a YogaNode to a parent without a measure function
.
Your best option (safest/better syntax highlighting wise) is to do it like so:
<Text>2 {'>'} 1</Text>
You could do it easily using the following manner:
let localizableString = 'Math inequality: 3 < 2x' //It is better to separate string literals from code for easier localization.
And then in your Component's file:
<Text {...textProps}>{localizableString}</Text>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With