diff options
author | 2018-08-27 16:06:26 +0300 | |
---|---|---|
committer | 2023-01-13 10:37:53 +0300 | |
commit | 97746777c5a9bfec059e2753307062180c08de3a (patch) | |
tree | 9fe6389af248d95a87bfaf614978758c03d421d4 /vnext/src | |
parent | 2bcad655fca844d06390e6431073a46091988f39 (diff) |
immutability-helper
Diffstat (limited to 'vnext/src')
-rw-r--r-- | vnext/src/components/Settings.js | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/vnext/src/components/Settings.js b/vnext/src/components/Settings.js index 2a24e35c..2f03671f 100644 --- a/vnext/src/components/Settings.js +++ b/vnext/src/components/Settings.js @@ -1,5 +1,7 @@ import React from 'react'; +import update from 'immutability-helper'; + import { me } from '../api'; import { UserType } from './Types'; @@ -39,9 +41,11 @@ export default class Settings extends React.Component { console.log('password update'); } emailChanged = (event) => { - this.setState({ - me: { activeEmail: event.target.value } + let newState = update(this.state, { + me: { activeEmail: {$set: event.target.value }} }); + this.setState(newState); + console.log('email update'); } disableTelegram = () => { console.log('telegram disable'); @@ -161,16 +165,16 @@ export default class Settings extends React.Component { {/** email_off **/} <form> You can receive notifications to email:<br /> - Sent to <select name="account" value={me.activeEmail} onChange={this.emailChanged}> + Sent to <select name="account" value={me.activeEmail || 'Disabled'} onChange={this.emailChanged}> <option value="">Disabled</option> - {me.emails.map(email => - <option key={email} value={email}> - {email} - </option> - )} + { + me.emails.map(email => + <option key={email} value={email}> + {email} + </option> + ) + } </select> - <input type="hidden" name="page" value="email-subscr" /> - <input type="submit" value="OK" /> </form> {/** /email_off **/} <p> </p> |