How to pass string and component as prop?

后端 未结 1 1262
感情败类
感情败类 2021-01-19 16:41

I can pass something like this fine:

{this.props.post.auth         


        
1条回答
  •  鱼传尺愫
    2021-01-19 17:05

    Try passing it as a React Element altogether, not as a string:

    
          This is a link: {this.props.post.author}
        
      }
    />
    

    Then should be able to render subtitle as is. If you're using React >16, you might want to use Fragments for this:

    import { Fragment } from 'react';
    
    // ...
    
    subtitle={
      
        This is a link: {this.props.post.author}
      
    }
    

    0 讨论(0)
提交回复
热议问题