【发布时间】:2022-07-07 17:03:22
【问题描述】:
我在 reactjs 中有这个对象作为状态。我想在“childoptions: []”数组中添加另一个对象,该数组嵌套在按钮单击时的选项数组中。
我怎样才能做到这一点,请帮助...
const [select1, setSelect1] = useState({
id: uuid(),
type: 'select',
properties: {
label: 'Select1',
options: [
// {
// id: uuid(),
// optionName: 'red ????',
// value: '',
// childOptions: [],
// },
// {
// id: uuid(),
// optionName: 'green ????',
// value: '',
// childOptions: [],
// },
// {
// id: uuid(),
// optionName: 'blue ????',
// value: '',
// childOptions: [],
// },
],
},
parentId: null,
});
【问题讨论】:
标签: reactjs arrays json react-hooks