class App extends React.Component {
constructor() {
super();
this.state = {
ListData: {}
}
}
componentDidMount() {
console.log(1)
var url = 'http://a.com/api'
reqwest({
url: url,
type: 'jsonp',
data: {
page: 1,
os: 16,
withext: 1
},
success: (e) =>{
var appListData = e.data
this.setState({
appListData: appListData
});
}
})
}
render() {
console.log(2)
return (
<div>
</div>
)
}
}
现在 控制台输出 2 1 2
最后一个2是 setState 时输出的么?这样的话会render2次,感觉不是很好,又什么好办法么?