React - How to pass HTML tags in props?

前端 未结 20 1292
甜味超标
甜味超标 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:28

    You can do it in 2 ways that I am aware of.

    1- This is not working.

    } />

    And then do this

    class MyComponent extends React.Component {
       render () {
         return (
    {this.props.text}
    ) } }

    Or second approach do it like this

    2-

    This is not working.

    And then do this

    class MyComponent extends React.Component {
       render () {
         return (
    {this.props.children}
    ) } }

提交回复
热议问题