score:1

Accepted answer

based on your quetion to merge the two state, you need to iterate over a state either 1 or 2, while merging them.

useeffects(() => {
 const keys = object.keys(state1);

 mergeddata = keys.map(key => {

  // key will be 0,1,2 as with your quetion
   return {
    ...state1[key],
    ...state2[key],
    fullname: state1[key].name + state2[key].lastname

   };
  });

}, [state1, state2]);

Related Query

More Query from same tag