Skip to content
Advertisement

How can I store and update multiple values in React useState?

I’ve a series of user data elements which I’m collecting inside a React component using hooks.

JavaScript

Each of these are updated as follows.

JavaScript

Is there a more succint way to do this using an object as the variable?

Advertisement

Answer

You should add name attributes to input tags. Each name must refer to key in AllValues object.

JavaScript
Advertisement