0

I have an array like this: subzones:{name , [rows]} Here rows is an array . I want to delete rows array from subzones array.

This is what i did:

deleteRows = (idx, sub_idx) => {
    // console.log(idx)
    var taskl = this.state.subzones
    var sub_taskl = this.state.subzones[idx].rows
    sub_taskl.splice(sub_idx, 1);
    taskl[idx].rows = sub_taskl
    this.setState({
        subzones: taskl
    });
    console.log("deleteRows", this.state.subzones)
};

But its not working . Any Suggestions?

5
  • please provide expected input and output with example. Question is not clear Commented Oct 17, 2020 at 6:00
  • There is a subzone array .Inside that rows field is there which is an array which i have to remove when clicking on delete button Commented Oct 17, 2020 at 6:01
  • Do you want to delete all rows from all subzone ? Commented Oct 17, 2020 at 6:02
  • No a particular row which i am clicking on that paricular row Commented Oct 17, 2020 at 6:06
  • 1
    Does this answer your question? React - remove nested array item using setState function call Commented Oct 17, 2020 at 6:12

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.