UNPKG

@hydevs/hypb

Version:

<img src="https://github.com/Hydevs-Corp/Hypb/blob/9308ab4c17196e5c0083c983a528326fd2cba867/.github/assets/banner.png" alt="usehooks-ts banner" align="center" />

21 lines (20 loc) 593 B
import { useEffect, useState } from 'react'; import { Hypb } from '../functions/pocketbase'; export function useAuthStore() { const [authStore, setAuthStore] = useState({ store: Hypb.pb.authStore, id: 0, }); useEffect(() => { const removeListener = Hypb.pb.authStore.onChange((_token, _model) => { setAuthStore((old) => ({ store: Hypb.pb.authStore, id: (old.id + 1) % 100, })); }, false); return () => { removeListener(); }; }, []); return { authStore }; }