Upgraded to next v15 and eslint to v9

This commit is contained in:
2024-10-23 12:18:24 +05:30
parent 65fc690787
commit 1f1b128b24
16 changed files with 622 additions and 570 deletions

View File

@ -1,12 +1,11 @@
import { useEffect } from 'react';
// eslint-disable-next-line no-unused-vars
type Callback = (entry: IntersectionObserverEntry) => void;
class IntersectionObserverManager {
private observer: IntersectionObserver;
private callbacks: Map<Element, Callback>;
// eslint-disable-next-line no-undef
constructor(options: IntersectionObserverInit) {
this.callbacks = new Map();
@ -44,7 +43,6 @@ class IntersectionObserverManager {
let manager: IntersectionObserverManager | null = null;
// eslint-disable-next-line no-undef
const getObserverManager = (options: IntersectionObserverInit) => {
if (!manager) {
manager = new IntersectionObserverManager(options);
@ -52,10 +50,7 @@ const getObserverManager = (options: IntersectionObserverInit) => {
return manager;
};
export const useSharedIntersectionObserver = (
// eslint-disable-next-line no-undef
options: IntersectionObserverInit,
) => {
export const useSharedIntersectionObserver = (options: IntersectionObserverInit) => {
useEffect(() => {
return () => {
// Cleanup logic if needed
@ -67,8 +62,11 @@ export const useSharedIntersectionObserver = (
if (typeof window === 'undefined') {
// Return a dummy manager for SSR
return {
// eslint-disable-next-line @typescript-eslint/no-empty-function
observe: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
unobserve: () => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
disconnect: () => {},
} as unknown as IntersectionObserverManager;
}

View File

@ -3,7 +3,6 @@ import { RefObject, useEffect, useRef, useState } from 'react';
import { useSharedIntersectionObserver } from './shared-intersection-observer';
// eslint-disable-next-line no-undef
interface UseInViewOptions extends IntersectionObserverInit {
triggerOnce?: boolean;
}