首页>demo05

Demo05 - PropTypes by zuojj at 30 Jun 2016

HTML

<div id="title"></div>

JAVASCRIPT

/**
 + 如果给_title not String type
 + Warning: Failed propType: Required prop `title` was not specified in `Title`
 */

var _title = '我是标题';
var Title = React.createClass({
    propTypes: {
        title: React.PropTypes.string.isRequired
    },
    render: function() {
        return <h1>{this.props.title}</h1>
    }
});

ReactDOM.render(<Title title={_title}/>, document.getElementById('title'));