how to update nested state properties in react hook code example

Example 1: access nested state value in hookstate

// However, there is a nested state method, which allows to access nested state by name.

// example :- 
state = {
  user: {
    name: { firstName: 'Kaushal', lastName: 'Shah' }
  }
};

// To access state => 
state

// To access user => 
state.user or state.nested('user')

// To access name => 
state.user.nested('name')

// To access firstName => 
state.user.nested('name').nested('firstName')

Example 2: react hooks update nested object

const onChange = (event) => {
    const s = {...style};
    s.font.align = event.target.value;
    setStyle(s);
}