【发布时间】:2021-06-19 11:40:26
【问题描述】:
如何将对象添加到反应钩子?我希望将 michael 和 philip 都存储在状态挂钩中。
export const app = () => {
const [state, setState] = useState({
name: "michael",
age: 55,
});
const name = "Philip";
const age = 65;
setState(...state, //How do I add the object with name: "Philip", age: 55 here?)
return <div></div>;
};
【问题讨论】:
标签: javascript reactjs object react-hooks jsx