Do not update state when the component is unmounted

Summary:
Bug:

{F176561921}

Reviewed By: danielbuechele

Differential Revision: D16763611

fbshipit-source-id: 93b95877f4818a9d2b2c7ba1b27eabaec41d4e95
This commit is contained in:
Pritesh Nandgaonkar
2019-08-12 14:46:32 -07:00
committed by Facebook Github Bot
parent 3401d1ef3c
commit 9a513ebd99
2 changed files with 12 additions and 8 deletions

View File

@@ -148,13 +148,15 @@ export default class ShareSheet extends Component<Props, State> {
} }
this.props.logger.trackTimeSince(mark, 'export:url-success'); this.props.logger.trackTimeSince(mark, 'export:url-success');
} catch (e) { } catch (e) {
const str = e instanceof Error ? e.toString() : e; if (!this.state.runInBackground) {
this.setState({ const str = e instanceof Error ? e.toString() : e;
result: { this.setState({
error_class: 'EXPORT_ERROR', result: {
error: str, error_class: 'EXPORT_ERROR',
}, error: str,
}); },
});
}
this.props.logger.trackTimeSince(mark, 'export:url-error'); this.props.logger.trackTimeSince(mark, 'export:url-error');
} }
} }

View File

@@ -140,7 +140,9 @@ export default class ShareSheetExportFile extends Component<Props, State> {
this.setState({errorArray, result: {success: true, error: null}}); this.setState({errorArray, result: {success: true, error: null}});
this.props.logger.trackTimeSince(mark, 'export:file-success'); this.props.logger.trackTimeSince(mark, 'export:file-success');
} catch (err) { } catch (err) {
this.setState({errorArray: [], result: {success: false, error: err}}); if (!this.state.runInBackground) {
this.setState({errorArray: [], result: {success: false, error: err}});
}
this.props.logger.trackTimeSince(mark, 'export:file-error'); this.props.logger.trackTimeSince(mark, 'export:file-error');
} }
} }