Layout improvements, some additions

This commit is contained in:
2020-11-29 07:03:22 +05:00
parent df69c05ff5
commit 8dcbdbdbd5
38 changed files with 2249 additions and 94 deletions

View File

@ -0,0 +1,25 @@
import { useState } from "react";
type ErrorT = {
message?: string;
has: boolean;
};
const useErrorHandler = <T extends Function>(
dispatcher: T
): {
error: ErrorT;
gotError: (err: Error) => void;
resetError: () => void;
} => {
const [error, setError] = useState<ErrorT>({ has: false });
const gotError = (err: Error) =>
setError({ has: true, message: dispatcher(err) });
const resetError = () => setError({ has: false });
return { error, gotError, resetError };
};
export default useErrorHandler;