mirror of
https://github.com/facebook/react.git
synced 2026-02-27 03:07:57 +00:00
## Summary as we began [discussing yesterday](https://github.com/facebook/react/pull/27056#discussion_r1253282784), `SuspenseList` is not actually stable yet, and should likely be exported with the `unstable_` prefix. the conversation yesterday began discussing this in the context of the fb-specific packages, but changing it there without updating everywhere else leads to test failures, so here the change is made across packages. ## How did you test this change? ``` yarn flow dom-browser yarn test ```
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
// Example
|
|
|
|
const x = React.createElement;
|
|
|
|
class ErrorBoundary extends React.Component {
|
|
static getDerivedStateFromError(error) {
|
|
return {
|
|
error: error,
|
|
};
|
|
}
|
|
|
|
componentDidCatch(error, errorInfo) {
|
|
console.log(error.message, errorInfo.componentStack);
|
|
this.setState({
|
|
componentStack: errorInfo.componentStack,
|
|
});
|
|
}
|
|
|
|
render() {
|
|
if (this.state && this.state.error) {
|
|
return x(
|
|
'div',
|
|
null,
|
|
x('h3', null, this.state.error.message),
|
|
x('pre', null, this.state.componentStack)
|
|
);
|
|
}
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
function Example() {
|
|
let state = React.useState(false);
|
|
return x(
|
|
ErrorBoundary,
|
|
null,
|
|
x(
|
|
DisplayName,
|
|
null,
|
|
x(
|
|
React.unstable_SuspenseList,
|
|
null,
|
|
x(
|
|
NativeClass,
|
|
null,
|
|
x(
|
|
FrozenClass,
|
|
null,
|
|
x(
|
|
BabelClass,
|
|
null,
|
|
x(
|
|
BabelClassWithFields,
|
|
null,
|
|
x(
|
|
React.Suspense,
|
|
null,
|
|
x('div', null, x(Component, null, x(Throw)))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
);
|
|
}
|