我正在学习本机反应。我没有弄清楚这个问题。我一直在我的项目中使用功能组件。这是我不明白转换类组件状态:
constructor(props) {
super(props)
this.state = {
center: { lat: 5.6219868, lng: -0.23223 },
locations: {},
users_online: [],
current_user: ''
}
}
/* this.setState((prevState, props) => {
let newState = { ...prevState };
newState.center = location;
newState.locations[`${prevState.current_user}`] = location;
return newState;
}); */ ==> I wan't to convert to functional component this state.
谢谢你的回答。!