React Base Fiddle (JSX)
Starting point for creating JSFiddles with React. This uses React with Addons.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.24/browser.js"></script>
<script src="https://fb.me/react-with-addons-0.14.6.js"></script>
<script src="https://fb.me/react-dom-0.14.6.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration-babel.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
CSS
.text {
}
.text__time {
color: #008080;
}
JavaScript 1.7
class Text extends React.Component {
constructor() {
super();
this.state = { currentTime: (new Date()).toString() };
}
componentDidMount() {
setInterval(() => this.updateCurrentTime(), 1000);
}
updateCurrentTime() {
this.setState({
currentTime: (new Date()).toString()
});
}
render() {
return <div className="text">
<span>Hello my name is { this.props.name }</span>
<span>And i was born { this.props.startDate }</span>
<span className="text__time">And i now it's { this.state.currentTime }</span>
</div>
}
};
let Paragraph = () => {
return <div className="MySuperTable">
<Text name="Dodo" startDate={ (new Date()).toString() } />
</div>
};
ReactDOM.render(
<Paragraph />,
document.getElementById('container')
);