mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
22 lines
396 B
JavaScript
22 lines
396 B
JavaScript
// Before
|
|
class ExampleComponent extends React.Component {
|
|
state = {
|
|
externalData: null,
|
|
};
|
|
|
|
// highlight-range{1-5}
|
|
componentWillMount() {
|
|
asyncLoadData(this.props.someId).then(externalData =>
|
|
this.setState({externalData})
|
|
);
|
|
}
|
|
|
|
render() {
|
|
if (this.externalData === null) {
|
|
// Render loading state ...
|
|
} else {
|
|
// Render real UI ...
|
|
}
|
|
}
|
|
}
|