Created
April 12, 2019 06:22
-
-
Save howtomakeaturn/f43c750bb5ddd0ca48a42f3f64f10d23 to your computer and use it in GitHub Desktop.
Revisions
-
howtomakeaturn created this gist
Apr 12, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ 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) }