echoes/frontend/hooks/useAsyncError.tsx

15 lines
279 B
TypeScript
Raw Normal View History

// File path: hooks/useAsyncError.tsx
import { useState, useCallback } from 'react';
export function useAsyncError() {
const [, setError] = useState();
return useCallback(
(e: Error) => {
setError(() => {
throw e;
});
},
[setError],
);
}