Soy un principiante de react.js y busco métodos para alterar mi estructura de datos. Por ejemplo, quiero insertar nuevos objetos en la matriz de niños o eliminarlos por clave.
¿Cuál es la forma adecuada de hacerlo?
const [treeData, setTreeData] = useState([ { title: "parent 1", key: "0-0", icon: <UserAddOutlined />, children: [ { title: "parent 1-0", key: "0-0-0", icon: <UserAddOutlined />, children: [ { title: "leaf", key: "0-0-0-0", icon: <UserAddOutlined />, }, { title: "leaf", key: "0-0-0-1", icon: <UserAddOutlined />, }, ], }, { title: "parent 1-1", key: "0-0-1", icon: <UserAddOutlined />, children: [ { title: "sss", key: "0-0-1-0", icon: <UserAddOutlined />, }, ], }, ], }, ]);