mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-13 08:37:53 -05:00
* wc/wagmi/viem * replace * profile * replace context (,: * testing, clean up * wallet connect deploy * connect * remove type slive * podcast * podcast * heck yeah * feat: connect button * chore * trying siwe, network switch * redirect * prettying, cleaning up SIWE endpoints, & passing linting 🕊 * switching minting to Optimism & converting `ethers` to `wagmi` for contract access 🥧 * simplified onboarding & successfully minted ⛲ * typo * api key --------- Co-authored-by: Udit Takkar <udit222001@gmail.com> Co-authored-by: dysbulic <dys@dhappy.org>
25 lines
589 B
TypeScript
25 lines
589 B
TypeScript
import { useEffect, useRef, useState } from 'react';
|
|
|
|
const useFirstViewportEntry: any = (ref: any, observerOptions: any) => {
|
|
const [entered, setEntered] = useState(false);
|
|
const observer = useRef(
|
|
new IntersectionObserver(
|
|
([entry]) => setEntered(entry.isIntersecting),
|
|
observerOptions,
|
|
),
|
|
);
|
|
|
|
useEffect(() => {
|
|
const element = ref.current;
|
|
const ob = observer.current;
|
|
if (entered) {
|
|
ob.disconnect();
|
|
}
|
|
if (element && !entered) ob.observe(element);
|
|
}, [entered, ref]);
|
|
|
|
return entered;
|
|
};
|
|
|
|
export default useFirstViewportEntry;
|