I need to save a data in this format:
categoryselect: 0: {
{
question: [],
cateName: 'checkbox'
name: '',
status: 1
}
},: 1: {
{
question: [],
cateName: 'checkbox'
name: '',
status: 1
}
},
Whenever I click new category I need to create a new object under categoryselect and if I click add new question I need to create an object under categoryselect[0].qustion[]. I tried like this but it doesn’t seem to do what I want:
this.setState({
categoryselect: [
this.state.categoryselect,
{
question: [
...this.state.categoryselect.question,
addQuestion
]
}
],
});
categoryselectas an object with numeric keys ?