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="app">
<!-- This element's contents will be replaced with your component. -->
</div>
Babel + JSX
class Hello extends React.Component {
handleClick() {
this.textBox.input.value = "I used ref";
}
render() {
return (
<div>
<TextBox ref={(ref)=>{this.textBox = ref; console.log('ref',ref)}}/>
<button onClick={this.handleClick.bind(this)}>Click Me</button>
</div>
)
}
}
class TextBox extends React.Component {
render() {
return(
<input ref={(ref) => {this.input = ref;console.log('ref2,',ref)}}>
</input>
)
}
}
ReactDOM.render(
<Hello/>,
document.getElementById('app')
)