How to Render a Formatted Template String In React JS

The Problem In Reactjssometimes we have to display the string in multiline but it does not work in reactjs. const [text, setText] = useState(`Some text \n next line`); output The Solution For solving this problem we can use either React Fragment tag or any valid JSX tag. const [text, setText] = useState( <> Some text <br /> next line </> ); output If you find it helpfull please share with your network ✅....

June 5, 2022 · 1 min · Mohammad Shahzaib