score:0

useEffect(() => {
  // Split the paragraph into words and lines
  const splittedText = Splitting({ target: paragraph, by: 'lines' });

  // Get an Array of Lines that contains an array of Words
  const lines = splittedText[0].lines.map(line =>
    line.map(word => word.textContent)
  );

  // Get every single lines as an Array of Strings
  const contents = lines.map(line => line.join(' '));

  // Hide the original paragraph
  paragraph.style.display = 'none';

  // Change the content state
  setContent({
    firstLine: contents[0],
    secondLine: contents[1],
    thirdLine: contents[2]
  });
}, []);

Related Query

More Query from same tag