I need to format text based on provided text specific style using react js. e.g:
Here i have observed one thing like, if i pass text with some variable e.g:
const text = "\nBubble\nAir\nSKY";
<myComponent variableText={text} />
Then inside my component when i inspect the passed data it shows like below:
"Bubble
Air
SKY"
If i get data like in this type of format, It is working fine for me. But when i direct pass the string text in my component like below:
<myComponent text="nBubblenAirnSky" />
So after inspect in the component passed text it shows same like string.
e.g: "nBubblenAirSKY";
How do we first get the string value as text in React js?
Need help
3
Answers
as i understood your component like this :
You can modify your component with your specific splitter do you want or you can use just an method like this :
If use this as Direct String it will be use as regular String , if you want to break the string you can use a
formatter
now in your Component you can use as you wish
then when you use it you can pass the string
const text = "nBubblenAirnSky";
Try to use dangerouslySetInnerHTML