Skip to content

Instantly share code, notes, and snippets.

@jobelenus
Created March 17, 2018 05:06
Show Gist options
  • Save jobelenus/0efd7f2821874736e188ca947bd49c4c to your computer and use it in GitHub Desktop.
Save jobelenus/0efd7f2821874736e188ca947bd49c4c to your computer and use it in GitHub Desktop.
addFoo(e, target_variable){
if(e.target.checked){
this.setState({
show: [...this.state.show, target_variable]})
}else{
var index = this.state.show.indexOf('target_variable');
if (index > -1) {
this.state.show.splice(index, 1);
this.setState({
show: [...this.state.show,]})
}
}
}
addBooks(e){
addFoo(e, 'books');
}
addMovies(e){
addFoo(e, 'movies');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment