useZigap
useZigap
is a hook that fetches the information of the logged-in user in the zigap app and provides a logout function.
Usage
import { useZigap } from 'zigap-utils';
Example
import { useZigap } from 'zigap-utils';
...
const Component = () => {
const { userInfo, logout, isWindowLoaded } = useZigap();
const handleLogout = () => {
if(isWindowLoaded) {
logout();
window.location.reload();
}
}
return (
<div>
<p>Address: {userInfo.address}</p>
<p>Network: {userInfo.network}</p>
<p>Nickname: {userInfo.nickName}</p>
<p>Token: {userInfo.token}</p>
<p>Issued DateTime: {userInfo.issuedDateTime}</p>
<p>Expire DateTime: {userInfo.expireDateTime}</p>
<button onClick={handleLogout}> LOGOUT </button>
</div>
);
}
UserInfo
name
type
address
string | undefined
network
string | undefined
nickname
string | undefined
token
string | undefined
issuedDateTime
string | undefined
expireDateTime
string | undefined
logout
It is a function that delete only the stored local storage value. Refresh the page if necessary.
Last updated