const [state,setState]={
"abc": 0,
"bce": 0,
"sal": 0,
"mek": [
{
"entityid": 0,
"ol": 0,
"salincomeId": 0,
"jCK": 0,
"description": "",
"AMT": 0,
"AA": 0
}
]
}
i have this object,i am handing it with onChange Event this works fine for outer object I am not able, onChange mek the array inside the object
const handleInput=(event,name)=>{
const value=event.target.value
setState({
...State,
[event.target.name]:value
})
how can i put values to mek here
I guess something like this. But you need to consider that it's an array.
const {value, name} = event.target;
this.setState((state) => ({
...state, mek[0]: { ...state.mek[0], [name]: [value] }
}))
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.