Skip to content

Instantly share code, notes, and snippets.

@andregardi
Created September 12, 2020 12:49
Show Gist options
  • Save andregardi/259e410e62fd2f8d82584a01b5097ac8 to your computer and use it in GitHub Desktop.
Save andregardi/259e410e62fd2f8d82584a01b5097ac8 to your computer and use it in GitHub Desktop.
const newWeatherItem = { ...state.cities[0].weatherStatus.current.weather[0], description: "Clear sky" }
const newWeather = [...state.cities[0].weatherStatus.current.weather]
newWeather[0] = newWeatherItem
const newCurrent = { ...state.cities[0].weatherStatus.current, weather: newWeather }
const newWeatherStatus = { ...state.cities[0].weatherStatus, current: newCurrent }
const newCities = [...state.cities]
newCities[0] = { ...newCities[0], weatherStatus: newWeatherStatus }
const newState = { ...state, cities: newCities }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment