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 React formatted string wrong method



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 React formatted string wrong method



If you find it helpfull please share with your network ✅.