React - How to pass HTML tags in props?

前端 未结 20 1302
甜味超标
甜味超标 2020-12-07 11:58

I want to be able to pass text with HTML tags, like so:

not working.\" />

Bu

20条回答
  •  一生所求
    2020-12-07 12:27

    Here is a solution that doesn't use the dangerouslySetInnerHTML which is dangerous as the name says.

    import { IntlProvider, FormattedMessage } from "react-intl";
    
     {chunks},
                i: (chunks) => {chunks},
                a: (chunks) => (
                  
                    {chunks}
                  
                )
              }}
            />
    

    This should be rendered as:

    Full example in https://jiga.dev/react-render-string-with-html-tags-from-props/

提交回复
热议问题