我正在尝试将新值设置为状态,但我无法使用方法执行此操作,状态仍然相同。
在这里宣布我的状态
this.state = {
notes: [],
selected: null
};
}
使用 componentDidMount 我可以更新状态
componentDidMount() {
this.setState({
notes: this.service.notes,
selected: {
title: "vazio",
text: "vazio"
}
});
}
但是当我使用这种方法更新时,状态仍然相同
onSelect(note) {
this.setState({
selected: note
});
}
杨魅力
幕布斯7119047
相关分类