在这里react新手。
我正在尝试匹配位于我所在州的特定 id 的值,因此我可以在通过我的 api 更新数据库之前更改一些值。
状态是
state = {
library: []
}
然后当 axios 改变状态时,数组看起来像:
0:{_id:"", time:"", value:""},
2:{_id:"", time:"", value:""}
当我运行 console.log 时,它是这样读取的。
(2) [{…}, {…}]0: {_id: "5c82803ad634ea0bebfb3eff", time: "2019-03-08T14:46:18.663Z", value:""}1: {_id: "5c827fb9d634ea0bebfb3efe", time: "2019-03-08T14:44:09.818Z", value:""}
所以基本上当我输入一个特定的输入字段时,由它的 _id 标识,我需要更新该特定状态的值状态。
这是我到目前为止编写的代码。_id 是我输入的输入字段和事件值的唯一键。
updateRead = (_id, event) => {
console.log(_id);
console.log(event.target.value)
this.setState(?????)
};
帮助将不胜感激!
干杯