react/docs/_js/examples/hello.js

16 lines
370 B
JavaScript
Raw Normal View History

var name = Math.random() > 0.5 ? 'Jane' : 'John';
var HELLO_COMPONENT = `
class HelloMessage extends React.Component {
render() {
return <div>Hello {this.props.name}</div>;
}
}
ReactDOM.render(<HelloMessage name="${name}" />, mountNode);
`.trim();
2013-05-30 03:46:11 +08:00
ReactDOM.render(
2013-05-30 03:46:11 +08:00
<ReactPlayground codeText={HELLO_COMPONENT} />,
document.getElementById('helloExample')
);