import React, { useState } from 'react';
import MakeError from '../error/MakeError';
import { ErrorFallback } from '../ErrorFallback';
import { ErrorBoundary } from '../index';

const FallbackExample = () => {
  const [retry, setRetry] = useState(0);

  return (
    <div>
      <button onClick={() => setRetry(retry + 1)}>retry</button>

      <ErrorBoundary FallbackComponent={ErrorFallback} resetKeys={[retry]}>
        <MakeError />
      </ErrorBoundary>
    </div>
  );
};

export default FallbackExample;
