14 lines
410 B
TypeScript
14 lines
410 B
TypeScript
|
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 };
|
||
|
}
|