'init'
This commit is contained in:
25
app/providers/AccountProvider/useLastLoginedAccount.ts
Normal file
25
app/providers/AccountProvider/useLastLoginedAccount.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function useLastLoginedAccount() : [
|
||||
string,
|
||||
(publicKey: string) => void
|
||||
] {
|
||||
const [lastLoginedAccount, setLastLogginedAccount] =
|
||||
useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
let publicKey =
|
||||
localStorage.getItem("last_logined_account");
|
||||
if(!publicKey){
|
||||
return;
|
||||
}
|
||||
setLastLogginedAccount(publicKey);
|
||||
}, []);
|
||||
|
||||
const setLastLogin = (publicKey: string) => {
|
||||
localStorage.setItem("last_logined_account", publicKey);
|
||||
setLastLogginedAccount(publicKey);
|
||||
}
|
||||
|
||||
return [lastLoginedAccount, setLastLogin];
|
||||
}
|
||||
Reference in New Issue
Block a user