How to use the react-error-boundary.withErrorBoundary function in react-error-boundary

To help you get started, we’ve selected a few react-error-boundary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joelshepherd / tabliss / src / containers / Plugin.tsx View on Github external
Component: React.ComponentType;
  data?: object;
};

const Plugin: React.FC = ({ id, Component, data }) => {
  // Plugin API this
  const api = useApi(id);
  const props: API = {
    ...api,
    data,
  };

  return ;
};

export default withErrorBoundary(Plugin, Crashed, captureException);

function useApi(id: string) {
  const dispatch = useDispatch();

  // Cache
  const cache = useSelector(state => state.cache[id]);
  const boundSetCache = React.useCallback(
    (cache: object) => dispatch(setCache(id, cache)),
    [dispatch, id],
  );

  // Data
  const boundSetData = React.useCallback(
    (data: object) => dispatch(setData(id, data)),
    [dispatch, id],
  );
github joelshepherd / tabliss / src / views / shared / Plugin.tsx View on Github external
import Crashed from './Crashed';
import { useApi } from '../../utils/useApi';

type Props = {
  id: string;
  Component: React.ComponentType>;
};

const Plugin: FC = ({ id, Component }) => {
  // Create plugin API
  const api = useApi(id);

  return ;
};

export default withErrorBoundary(Plugin, Crashed, captureException);
github universitas / universitas.no / webpack / src / universitas / components / PageSwitch / PageSwitch.js View on Github external
const pageWrapper = (Page, toTitle = R.F) => {
  const title = R.pipe(
    toTitle,
    R.unless(R.is(String), R.always('')),
    R.trim,
    capitalize,
  )
  const locationToProps = R.pipe(
    R.converge(R.merge, [R.prop('payload'), R.pick(['pathname'])]),
    R.converge(R.assoc('pageTitle'), [title, R.identity]),
  )
  return [withErrorBoundary(Page, undefined, onError), locationToProps]
}

react-error-boundary

Simple reusable React error boundary component

MIT
Latest version published 16 days ago

Package Health Score

97 / 100
Full package analysis

Similar packages