You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
627 B

// After
class ExampleComponent extends React.Component {
state = {
externalData: null,
};
// highlight-range{1-9}
componentDidMount() {
this._currentRequest = asyncLoadData(
this.props.someID,
externalData => {
this._currentRequest = null;
this.setState({externalData});
}
);
}
// highlight-line
// highlight-range{1-5}
componentWillUnmount() {
if (this._currentRequest) {
this._currentRequest.cancel();
}
}
render() {
if (this.externalData === null) {
// Render loading state ...
} else {
// Render real UI ...
}
}
}