How do I convert a string to jsx?

前端 未结 8 1997
Happy的楠姐
Happy的楠姐 2020-11-27 20:19

How would I take a string, and convert it to jsx? For example, if I bring in a string from a textarea, how could I convert it to a React

8条回答
  •  执笔经年
    2020-11-27 20:48

    Here's a little utility component for this:

    const RawHtml = ({ children="", tag: Tag = 'div', ...props }) =>
      ;
    

    Sample usage:

    
      {"Lorem
    ipsum"}

提交回复
热议问题