score:2

Accepted answer

looks like you did override your name & age again in mapstatetoprop function which only state should be returned in the function:

const maptoprop = (state) => {
  return {
    ...state,
    // you would nee to remove this overrides
    // name: "sagar",
    // age: "22"
  }
}

score:0

with the updation in @tmhao2005's answer , i updated -

const maptoprop=(state)=>{
  return{
    ...state,
    name:state.name==null?"sagar":state.name
    //age:"22"
  }
}

this started working. all credit to @tmhao2005 , as without his initial answer wont have been reached to this point.


Related Query

More Query from same tag