class BidInfo extends Component {
constructor(props){
super(props);
this.state={
current_page: 2,
form_data: null
}
}
handle () {
this.setState({form_data: 1})
}
render() {
var value = this.state.form_data;
return(
<div>
<QuickSearch />
<InfoList />
<input type="button" value="按钮" onClick={this.handle()} />
<div>{value}</div>
</div>
)
}
}
export default BidInfo
报错
Warning: setState(...): Cannot update during an existing state transition (such as within render
or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to componentWillMount
.