React - How to pass HTML tags in props?

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

    You could also use a function on the component to pass along jsx to through props. like:

     var MyComponent = React.createClass({
    
       render: function() {
        return (
          
        );
       },
    
       body() {
         return(
           

    This is now working.

    ); } }); var OtherComponent = React.createClass({ propTypes: { body: React.PropTypes.func }, render: function() { return (

    {this.props.body()}
    ); }, });

提交回复
热议问题