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>
JavaScript 1.7
var YourComponent = React.createClass({
getInitialState: function() {
return {
arrayone: [{
"id": "1",
"city": "New York"
}, {
"id": "2",
"city": "Brooklyn"
}],
arraytwo: [{
"id": "101",
"city": "Hamburg"
}, {
"id": "102",
"city": "Schalke"
}]
}
},
buttonFunc: function() {
var cloneArrayone = JSON.parse(JSON.stringify(this.state)).arrayone;
cloneArrayone[0].city = "Tokyo";
this.setState({
arrayone: cloneArrayone,
arraytwo: cloneArrayone
});
},
buttonFunc2: function() {
var cloneArrayone = JSON.parse(JSON.stringify(this.state)).arrayone;
cloneArrayone[0].city = "Pakistan";
this.setState({
arrayone: cloneArrayone
});
},
render: function() {
return (
<div>
<button onClick={this.buttonFunc}>button 1</button><br />
<button onClick={this.buttonFunc2}>button 2</button><br />
{JSON.stringify(this.state.arrayone)}<br />
{JSON.stringify(this.state.arraytwo)}
</div>
)
}
});
ReactDOM.render( <YourComponent /> ,
document.getElementById('container')
);