ErrorBoundary
Summary: _typescript_ Reviewed By: bnelo12 Differential Revision: D16830532 fbshipit-source-id: 482d16194cfe8547b9926a0b9b08cfc9e2b46972
This commit is contained in:
committed by
Facebook Github Bot
parent
9159256a3c
commit
84092534ce
@@ -5,12 +5,13 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ErrorBlock from './ErrorBlock.js';
|
import ErrorBlock from './ErrorBlock';
|
||||||
import {Component} from 'react';
|
import {Component} from 'react';
|
||||||
import Heading from './Heading.tsx';
|
import Heading from './Heading';
|
||||||
import Button from './Button.js';
|
import Button from './Button';
|
||||||
import View from './View.tsx';
|
import View from './View';
|
||||||
import styled from '../styled/index.js';
|
import styled from 'react-emotion';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
const ErrorBoundaryContainer = styled(View)({
|
const ErrorBoundaryContainer = styled(View)({
|
||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
@@ -24,25 +25,25 @@ const ErrorBoundaryStack = styled(ErrorBlock)({
|
|||||||
|
|
||||||
type ErrorBoundaryProps = {
|
type ErrorBoundaryProps = {
|
||||||
/** Function to dynamically generate the heading of the ErrorBox. */
|
/** Function to dynamically generate the heading of the ErrorBox. */
|
||||||
buildHeading?: (err: Error) => string,
|
buildHeading?: (err: Error) => string;
|
||||||
/** Heading of the ErrorBox. Used as an alternative to `buildHeading`. */
|
/** Heading of the ErrorBox. Used as an alternative to `buildHeading`. */
|
||||||
heading?: string,
|
heading?: string;
|
||||||
/** Whether the stacktrace of the error is shown in the error box */
|
/** Whether the stacktrace of the error is shown in the error box */
|
||||||
showStack?: boolean,
|
showStack?: boolean;
|
||||||
/** Code that might throw errors that will be catched */
|
/** Code that might throw errors that will be catched */
|
||||||
children?: React$Node,
|
children?: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ErrorBoundaryState = {|
|
type ErrorBoundaryState = {
|
||||||
error: ?Error,
|
error: Error | null | undefined;
|
||||||
|};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boundary catching errors and displaying an ErrorBlock instead.
|
* Boundary catching errors and displaying an ErrorBlock instead.
|
||||||
*/
|
*/
|
||||||
export default class ErrorBoundary extends Component<
|
export default class ErrorBoundary extends Component<
|
||||||
ErrorBoundaryProps,
|
ErrorBoundaryProps,
|
||||||
ErrorBoundaryState,
|
ErrorBoundaryState
|
||||||
> {
|
> {
|
||||||
constructor(props: ErrorBoundaryProps, context: Object) {
|
constructor(props: ErrorBoundaryProps, context: Object) {
|
||||||
super(props, context);
|
super(props, context);
|
||||||
@@ -82,7 +82,7 @@ export {default as CodeBlock} from './components/CodeBlock.js';
|
|||||||
// error
|
// error
|
||||||
export {default as ErrorBlock} from './components/ErrorBlock.js';
|
export {default as ErrorBlock} from './components/ErrorBlock.js';
|
||||||
export {ErrorBlockContainer} from './components/ErrorBlock.js';
|
export {ErrorBlockContainer} from './components/ErrorBlock.js';
|
||||||
export {default as ErrorBoundary} from './components/ErrorBoundary.js';
|
export {default as ErrorBoundary} from './components/ErrorBoundary.tsx';
|
||||||
|
|
||||||
// interactive components
|
// interactive components
|
||||||
export type {OrderableOrder} from './components/Orderable.tsx';
|
export type {OrderableOrder} from './components/Orderable.tsx';
|
||||||
|
|||||||
Reference in New Issue
Block a user