DEV Community

Ashish Kumar
Ashish Kumar

Posted on

How to update object key in useState

To update an object key in the state select the key and assign its value to that state

    onClick={(e) =>
            setBooks((prev) => ({
              ...prev,
              physics: e.target.value,
            }))
          }
Enter fullscreen mode Exit fullscreen mode

read more

Top comments (0)