const [columns, setColumns] = useState({
Configured: {
progress: "Configured",
tasks: [],
},
Approved: {
progress: "Approved",
tasks: [],
},
AwaitingPO: {
progress: "Awaiting PO",
tasks: [],
},
InProduction: {
progress: "In-Production",
tasks: [],
},
Delivered: {
progress: "Delivered",
tasks: [],
},
});
const { loading, error, data } = useQuery(GET_CUSTOMERS);
useEffect(() => {
if (data) {
data.customer.map((item) => {
setColumns({
...columns,
[item.progress]: {
...columns[item.progress],
tasks: [
...columns[item.progress].tasks, ///Spread operator not working here
item
],
},
});
});
}
}, [data]);
我正在尝试将多个指定的对象添加item到我的tasks数组中。在我拥有的三项中,仅添加了一项。嵌套状态似乎相当困难,我觉得我在useEffect地图函数本身方面做了一些错误的事情。
HUH函数
12345678_0001
相关分类