react hook which is pretty cool to manage global state change

when anything in useCallback dep array changes in the whole app’s context

it will call the function in useCallback again

so if i have this code in /app/admin/layout.tsx

  const wallet = useWallet();
  const authorizedWallets = useMemo(
    () => [
      "2cBTVAbdrqTqoiHyTKv4RWfXhXv6mHqbzqzszhJRswti",
      "8rfvBqQ1yybiBfTfdemaED45SiEEK2Bt6b59XGQLhxqF",
    ],
    []
  );
  const [allow, setAllow] = useState(false);
 
  // only allow if admin wallet is connected
  const checkAuthorization = useCallback(() => {
    if (
      wallet.publicKey &&
      authorizedWallets.includes(wallet.publicKey.toString())
    ) {
      setAllow(true);
    } else {
      setAllow(false);
    }
  }, [wallet, authorizedWallets]);
 
  useEffect(() => {
    checkAuthorization();
  }, [checkAuthorization]);
 
 

useEffect is triggered even if wallet changes in another page in the app

i find it extremely cool