/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
v17.0.0
fixtures/stacks/Example.js
67 строк
1 KB
Sebastian Markbåge
Fix Component Stacks for IE and Native Classes in Safari (#18575)
11 апр 2020, 05:39
Не верифицирован
11 апр 2020, 05:39
72d00ab
Код
Авторство
О чём код?
// 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.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))) ) ) ) ) ) ) ) ); }