如果我有这样的两个组件(父子组件):
1-父母(倒计时):
var Countdown = React.createClass({
getInitialState: function(){
return{count: 0};
},
handleSetCountdown: function(seconds){
this.setState({
count: seconds
});
},
render:function(){
var {count} = this.state;
return(
<div>
<Clock totalSeconds={count}/>
<CountdownForm onSetCountdown={this.handleSetCountdown} />
</div>
);
}
});
module.exports =Countdown;
2-孩子(倒计时形式):
var CountdownForm = React.createClass({
onSubmit: function(e){
e.preventDefault();
var strSeconds = this.refs.seconds.value;
if(strSeconds.match(/^[0-9]*$/)){
this.refs.seconds.value ='';
this.props.onSetCountdown(parseInt(strSeconds,10));
}
},
render: function(){
return(
<div>
<form ref="form" onSubmit={this.onSubmit} className="countdown-form">
<input type="text" ref="seconds" placeholder="Enter Time In Seconds"/>
<button className="button expanded">Start</button>
</form>
</div>
);
}
});
module.exports = CountdownForm;
我对生命周期(组件呈现的顺序)感到困惑?