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,6 +148,7 @@ 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) {
if (!this.state.runInBackground) {
const str = e instanceof Error ? e.toString() : e; const str = e instanceof Error ? e.toString() : e;
this.setState({ this.setState({
result: { result: {
@@ -155,6 +156,7 @@ export default class ShareSheet extends Component<Props, State> {
error: str, 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) {
if (!this.state.runInBackground) {
this.setState({errorArray: [], result: {success: false, error: err}}); this.setState({errorArray: [], result: {success: false, error: err}});
}
this.props.logger.trackTimeSince(mark, 'export:file-error'); this.props.logger.trackTimeSince(mark, 'export:file-error');
} }
} }