【问题标题】:When I render my user input from a textarea in react, all of the formatting (line-breaks and tabs) are automatically removed, how do I change that?When I render my user input from a textarea in react, all of the formatting (line-breaks and tabs) are automatically removed, how do I change that?
【发布时间】:2022-12-27 21:14:51
【问题描述】:

How my text appears when rendered How my text appears in the textarea input

I am posting multi-paragraph blogs, some about poetry (where line breaks and spacings matter a lot). How do I make the line breaks and other spacing stay when I render the data? Can I make it so the user can put html tags in the textarea somehow? I am using firebase realtime database to store the data.

I tried changing the HTML tag in the rendered component from p to per, expecting to be able to use html tags, but that didn't work.

【问题讨论】:

    标签: reactjs textarea user-input text-rendering


    【解决方案1】:

    write this code on css file

    white-space: pre-wrap;
    

    【讨论】:

      猜你喜欢
      • 2022-12-02
      • 2022-12-02
      • 2019-09-29
      • 2022-12-02
      • 2022-12-27
      • 2022-12-19
      • 1970-01-01
      • 2022-08-17
      • 2022-04-20
      相关资源
      最近更新 更多