/
githubmr
/
facebook-react
Обзор
Документация
Войти
/
githubmr
/
facebook-react
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
fixtures/stacks/Example.js
70 строк
1 KB
Josh Story
[UMD] Remove umd builds (#28735)
17 апр 2024, 21:15
Не верифицирован
17 апр 2024, 21:15
da6ba53
Код
Авторство
О чём код?
import {BabelClass, BabelClassWithFields} from './BabelClasses-compiled.js'; import { Throw, Component, DisplayName, NativeClass, FrozenClass, } from './Components.js'; 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; } } export default function Example() { let state = React.useState(false); return x( ErrorBoundary, null, x( DisplayName, 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))) ) ) ) ) ) ) ); }