1
export interface Address {
    id: string,
    formData: FormData,
    addressData: AddressData,
    documentsData: DocumentsData
}

export interface AddressData {
    professional: AddressProfessional;
}

export interface AddressProfissional {
    typeA: AddressTypeA[];
    typeB: AddressTypeB[];
}

export interface AddressTypeA {
   name: string;
   surname: string;
   address: string;
   city: string;
   country: string;
}

I can update the store, but not sure what is the best way to update nested state, for example if I want to update the addressData -> AddressTypeA and update only the object being send that is {name & surname}

functionUpdateStore(data  => {
     this.store.update(state => ({
        ...state,
        addressData: data,
     }))
});

payload being send to update the store: name: string; surname: string;

Currently the store is being updated but not in the nested property. What is the best way to update nested object state?

bernlt
  • 405
  • 2
  • 8
  • 20

0 Answers0