user4061275
user4061275

Reputation:

how to update React State while on change

this is my initial state

const [state, setState] = React.useState({ fleet: {makeId: 867,....}, });

onChange I need to update the makeId.

setState({...state, ?})

How can I achieve this?

Upvotes: 0

Views: 64

Answers (1)

Md Sabbir Alam
Md Sabbir Alam

Reputation: 5064

You can write something like this,

setState({...state, fleet: {...state.fleet, makeId: YourMakeId });

That should do the trick.

Upvotes: 4

Related Questions