tab切换的时候更新当前选择的tab,debugger发现state并没有更新,请问具体原因是什么,万分感谢!
constructor(props) { super(props) this.state = { selected: 'blacklist' } }
tabChange(newSelected) { // newSelected = "score" const {selected} = this.state; // selected = "blacklist" debugger if (selected !== newSelected) { // selected = "blacklist", newSelected = "score" this.setState({ selected: newSelected, }) const {tabChange} = this.props tabChange(newSelected) } debugger const state = this.state //state = {selected: "blacklist",} console.log(state) }
cnyballk
www说
慕的地8271018