Simplify calls to setState, apparently it already shallow merges.

master
Tom Hacohen 7 years ago
parent f8ee484c3b
commit 3faa7b3ed6

@ -92,9 +92,7 @@ export class EteSyncContext extends React.Component {
errors.errorEncryptionPassword = fieldRequired; errors.errorEncryptionPassword = fieldRequired;
} }
if (Object.keys(errors).length) { if (Object.keys(errors).length) {
this.setState(Object.assign( this.setState({errors: errors});
{}, this.state,
{errors: errors}));
return; return;
} }
@ -127,9 +125,7 @@ export class EteSyncContext extends React.Component {
} }
toggleAdvancedSettings() { toggleAdvancedSettings() {
this.setState(Object.assign( this.setState({showAdvanced: !this.state.showAdvanced});
{}, this.state,
{showAdvanced: !this.state.showAdvanced}));
} }
render() { render() {

@ -39,12 +39,12 @@ export class JournalView extends React.Component {
let journalManager = new EteSync.JournalManager(credentials, apiBase); let journalManager = new EteSync.JournalManager(credentials, apiBase);
journalManager.fetch(journal).then((journalInstance) => { journalManager.fetch(journal).then((journalInstance) => {
this.setState(Object.assign({}, this.state, { journal: journalInstance })); this.setState({ journal: journalInstance });
}); });
let entryManager = new EteSync.EntryManager(credentials, apiBase, journal); let entryManager = new EteSync.EntryManager(credentials, apiBase, journal);
entryManager.list(this.props.prevUid || null).then((entries) => { entryManager.list(this.props.prevUid || null).then((entries) => {
this.setState(Object.assign({}, this.state, { entries })); this.setState({ entries });
}); });
} }

Loading…
Cancel
Save