I have a state like :
data: Object
value: []
and I have some return value like:
{'name': 'myname'}
{'gender': 'male'}
Here I want to update each value simoltaneously calling dispatch:
When I call dispatch({data}, type: ADD_DATA})
where data are each values in loop. I want the result like:
data: Object
value: [{
'type': 'personal',
'info':[
{'name': 'myname'},
{'gender': 'male'}
]
}]
I am stuck at here :
return Object.assign({}, state, {data: Object.assign({}, state.data, {value: null})})
Can I get some help ?
var person = {
type: 'personal',
info: yourDataHere
};
return Object.assign({}, state, {data: Object.assign({}, data, {
value: state.data.value.concat(person)
})});
I'm assuming that yourDataHere
is
[
{'name': 'myname'},
{'gender': 'male'}
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.