Skip to content Skip to sidebar Skip to footer

React-native : Update Object With SetState

Is it possible to update object using setState? updateState = () => { let updateThis = '2019-06-30 //I want to update pressedDate's updateThis with '2019-06-30' thi

Solution 1:

I am not sure i get you completely, but you should set the updateThis key to the the date

    updateState = () => {
    let updateThis = '2019-06-30

   //I want to update pressedDate's updateThis with '2019-06-30'

   this.setState(({pressedDate}) => ({
    pressedDate: {
       ...pressedDate,
       updateThis : updateThis
     }
    }))
  }

Post a Comment for "React-native : Update Object With SetState"