From 3faa7b3ed6eb74b61fb2810af4859d5a43bf9eac Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 4 Dec 2017 16:50:54 +0000 Subject: [PATCH] Simplify calls to setState, apparently it already shallow merges. --- src/EteSyncContext.tsx | 8 ++------ src/JournalView.tsx | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/EteSyncContext.tsx b/src/EteSyncContext.tsx index 4a66849..f1da1e3 100644 --- a/src/EteSyncContext.tsx +++ b/src/EteSyncContext.tsx @@ -92,9 +92,7 @@ export class EteSyncContext extends React.Component { errors.errorEncryptionPassword = fieldRequired; } if (Object.keys(errors).length) { - this.setState(Object.assign( - {}, this.state, - {errors: errors})); + this.setState({errors: errors}); return; } @@ -127,9 +125,7 @@ export class EteSyncContext extends React.Component { } toggleAdvancedSettings() { - this.setState(Object.assign( - {}, this.state, - {showAdvanced: !this.state.showAdvanced})); + this.setState({showAdvanced: !this.state.showAdvanced}); } render() { diff --git a/src/JournalView.tsx b/src/JournalView.tsx index 422045b..c63d42d 100644 --- a/src/JournalView.tsx +++ b/src/JournalView.tsx @@ -39,12 +39,12 @@ export class JournalView extends React.Component { let journalManager = new EteSync.JournalManager(credentials, apiBase); 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); entryManager.list(this.props.prevUid || null).then((entries) => { - this.setState(Object.assign({}, this.state, { entries })); + this.setState({ entries }); }); }