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

logout

It is a function that delete only the stored local storage value. Refresh the page if necessary.

Last updated