Skip to content

Instantly share code, notes, and snippets.

@blizzerand
Created November 30, 2018 11:35
Show Gist options
  • Save blizzerand/506bd97c6e6685c3d8a88b28e4069420 to your computer and use it in GitHub Desktop.
Save blizzerand/506bd97c6e6685c3d8a88b28e4069420 to your computer and use it in GitHub Desktop.
handleCheckBox(e) {
const newSelection = e.target.value;
let newSelectionArray;
if(this.state.newUser.skills.indexOf(newSelection) > -1) {
newSelectionArray = this.state.newUser.skills.filter(s => s !== newSelection)
} else {
newSelectionArray = [...this.state.newUser.skills, newSelection];
}
this.setState( prevState => ({ newUser:
{...prevState.newUser, skills: newSelectionArray }
})
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment