How do I convert a string to jsx?

前端 未结 8 2000
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:26

    You can consider using the React attribute dangerouslySetInnerHTML:

    class YourComponent{
      render() {
        someHtml = '
    blablabla

    another blbla

    ' return (
    ) } }

提交回复
热议问题