How do I make a line break in the previewer when the user presses enter in the editor

Hello, how do I make a line break in the previewer when the user presses enter in the editor. I pass my code:

const App = () => {
    const [data, setData] = useState ('');
   
    const onChange = (e) => {
     setData (e.target.value)
    }

const onKeyPressHandler = (event) => {
     if (event.keyCode === 13) {
        
     }
   }
  
return (
    
<div>
    
     <div id = "editor">
         <h3> Editor </h3>
         <textarea value = {data} onChange = {onChange} onKeyDown = {onKeyPressHandler}> </textarea>
        
     </div>

     <div id = "previewer">
         <h3> Previewer </h3>
         <div> {data} </div>
     </div>
    
</div>

)};

export default App;

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

You can look into the documentation under marked.setOptions
https://marked.js.org/using_advanced

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.