Skip to content

Instantly share code, notes, and snippets.

@profesor79
Created September 18, 2018 17:36
Show Gist options
  • Save profesor79/84a2754a853bd0308b36f9a4e7b8b271 to your computer and use it in GitHub Desktop.
Save profesor79/84a2754a853bd0308b36f9a4e7b8b271 to your computer and use it in GitHub Desktop.
how we can dry it?
resetSelectedState() {
const geoElement = Object.assign([], this.state.states); // create new copy to avoid mutation
geoElement.forEach((a) => a.isSelected = false);
this.setState({ states: geoElement });
}
resetSelectedCountry() {
const geoElement = Object.assign([], this.state.countries); // create new copy to avoid mutation
geoElement.forEach((a) => a.isSelected = false);
this.setState({ countries: geoElement });
}
resetSelectedContinent() {
const geoElement = Object.assign([], this.state.continents); // create new copy to avoid mutation
geoElement.forEach((a) => a.isSelected = false);
this.setState({ continents: geoElement });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment