This file contains 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 characters
updateAvatar(e) { | |
// Grab the name + value from the select | |
const target = e.target; | |
const { name, value } = target; | |
// Spread + destructure the options from state | |
const { options } = { ...this.state }; | |
// Update the matching option with | |
// the value of the select and set state | |
const currentState = options; | |
currentState[name] = value; |
This file contains 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 characters
displayAvatar() { | |
// Object.keys / values creates an array | |
const keys = Object.keys(this.state.options); | |
const values = Object.values(this.state.options); | |
// Map through the keys array and pair each result with | |
// the matching index of the values array, adding in | |
// necessary symbols where | |
const keyValue = keys.map((e, i) => e + "=" + values[i] + "&"); | |
// Use .join('') to convert into a string | |
const joined = keyValue.join(""); |