This is a code for a simple counter.
However, when i Render the view i don't get any output. Please tell me what is wrong with the code.
The button is pressed and a counter is incremented and is rendered onto the screen.
var Title = React.createClass({
getInitialState : function(){
return {count:0};
},
increment : function(){
this.setState({count:this.state.count+this.props.incVal});
},
render: function() {
return (
<div>
<h1 >Count : {this.state.count}< /h1>
<button onClick={this.increment} >Increment</button>
</div>
);
}
});
var MultiButton = React.createClass({
render : function (){
return(
<Title incVal={1}/>
<Title incVal={5}/>
);
}
});
ReactDOM.render( <MultiButton /> ,
document.getElementById('example')
);
Aucun commentaire:
Enregistrer un commentaire