React - How to pass HTML tags in props?

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

    This is not working.} />
    

    and then in your component you can do prop checking like so:

    import React from 'react';
    export default class MyComponent extends React.Component {
      static get propTypes() {
        return {
          text: React.PropTypes.object, // if you always want react components
          text: React.PropTypes.any, // if you want both text or react components
        }
      }
    }
    

    Make sure you choose only one prop type.

提交回复
热议问题