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/react/0.13.1/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.1/react-with-addons.js"></script>
<script src="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
<div id="container">
<!-- This element's contents will be replaced with your component. -->
</div>
CSS
span div {
display:inline-block;
background: black; color: white; padding: 30px; font-size: 24px;
}
.example-enter {
opacity: 0.01;
transition: opacity 1.5s ease-in;
}
.example-enter.example-enter-active {
opacity: 1;
}
.example-leave {
opacity: 1;
transition: opacity 1.5s ease-in;
}
.example-leave.example-leave-active {
opacity: 0.01;
}
JavaScript 1.7
var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
var Hello = React.createClass({
getInitialState: function() {
return {on: true};
},
onClick: function() {
this.setState({on: !this.state.on});
},
render: function() {
var k = this.state.on ? (<div> Hello {this.props.name} </div>) : "";
return <div>
<a href="#" onClick={this.onClick}> Click to toggle </a> <br/> <br/>
<ReactCSSTransitionGroup transitionName="example">
{k}
</ReactCSSTransitionGroup>
</div>;
}
});
React.render(<Hello name="World" />, document.getElementById('container'));