Skip to content

Instantly share code, notes, and snippets.

@howtomakeaturn
Created April 12, 2019 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save howtomakeaturn/f43c750bb5ddd0ca48a42f3f64f10d23 to your computer and use it in GitHub Desktop.
Save howtomakeaturn/f43c750bb5ddd0ca48a42f3f64f10d23 to your computer and use it in GitHub Desktop.
changeOptionValue(optionIndex, valueIndex, newValue) {
const state = this.state;
const newState = {
...state,
options: state.options.map((option, i) =>
i === optionIndex ?
{ ...option, values: option.values.map((value, ii) =>
ii === valueIndex ?
newValue : value
)
} :
option
)
};
this.setState(newState)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment