在我的项目中,我有react-native-calendar
,并且当我单击某天时,我正在尝试更新自己的mobx
state
。
我的代码工作正常,但是当我单击两次时它只会更新mobx state
。
updateState = (day) => {
const _selectedDay = moment(day.dateString).format(_format);
this.setState(({pressedDate}) => ({
pressedDate: {
[_selectedDay] : {
dots: [this.state.vacation, this.state.massage, this.state.workout,this.state.study],selected: this.state.update
}
},
selectedDay:_selectedDay
}))
//Here I update mobx state
store.selectedDay = this.state.selectedDay
//console.log see changes
console.log(store.selectedDay,'check selectedDay')
}
如何在不称呼它的情况下进行这项工作?