import { storiesOf } from '@storybook/react'; import React from 'react'; import { useError } from '../src'; import ShowDocs from './util/ShowDocs'; class ErrorBoundary extends React.Component<{}, { hasError: boolean }> { constructor(props) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error) { return { hasError: true }; } render() { if (this.state.hasError) { return (

Something went wrong.

); } return this.props.children; } } const Demo = () => { const dispatchError = useError(); const clickHandler = () => { dispatchError(new Error('Some error!')); }; return ; }; storiesOf('Side effects/useError', module) .add('Docs', () => ) .add('Demo', () => ( ));