dsql-admin/dsql-app/hooks/useLocalUser.ts

14 lines
410 B
TypeScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
import { UserType } from "@/package-shared/types";
import React from "react";
export default function useLocalUser() {
const [user, setUser] = React.useState<UserType | undefined>();
React.useEffect(() => {
try {
const localUserJSON = localStorage.getItem("user");
setUser(JSON.parse(localUserJSON || ""));
} catch (error) {}
}, []);
return { user };
}