Skip to content

Commit

Permalink
fix: html element ref object null type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Fingertips18 committed Jan 18, 2025
1 parent b9d0389 commit ba198c1
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/hooks/useObserver.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RefObject, useEffect, useState } from "react";

interface useObserverProps {
elementRef: RefObject<HTMLElement>;
elementRef: RefObject<HTMLElement | null>;
threshold?: number;
root?: Element | Document | null;
rootMargin?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/root/_components/contact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { OtherContacts } from "./other-contacts";
import { ContactForm } from "./contact-form";

const Contact = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });

return (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/root/_components/education/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { VerticalTimeline } from "react-vertical-timeline-component";
import { useObserver } from "@/lib/hooks/useObserver";
import { GraduationCap } from "lucide-react";
import { useRef } from "react";

import { QUERYELEMENT, ROOTSECTION } from "@/constants/enums";
import { useObserver } from "@/lib/hooks/useObserver";
import { EDUCATIONS } from "@/constants/education";
import { cn } from "@/lib/utils";

import EducationItem from "./education-item";

const Education = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/root/_components/experience/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { cn } from "@/lib/utils";
import { TimelineItem } from "./timeline-item";

const Experience = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/root/_components/hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TypingTexts } from "./typing-texts";
import SocialButtons from "./social-buttons";

const Hero = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });
const isMounted = useMounted();
const { width } = useResize();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/root/_components/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cn } from "@/lib/utils";
import { ProjectItem, ProjectItemSkeleton } from "./project-item";

const Projects = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });

return (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/root/_components/skills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Others } from "./others";
import { Tools } from "./tools";

const Skills = () => {
const sectionRef = useRef<HTMLElement>(null);
const sectionRef = useRef<HTMLElement | null>(null);
const { isVisible } = useObserver({ elementRef: sectionRef });

return (
Expand Down

0 comments on commit ba198c1

Please sign in to comment.