Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

surfiniaburger #341

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ A GitHub conflict is when people make changes to the same area or line in a file

- ### **A**

- [Adedoyinsola Ogungbesan](https://github.com/surfiniaburger)
- [Alimurtuza Patrawala](https://github.com/CYBWEBALI)
- [Arslan Malik](https://github.com/ArslanYM)
- [Ashwanthram K L](https://github.com/AshwanthramKL)
Expand Down
11 changes: 4 additions & 7 deletions web/src/hooks/useInterectionObserver.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useEffect, useRef, useState } from "react";
import PropTypes from "prop-types";

export const useInterectionObserver = (margin = "0px") => {
export const useIntersectionObserver = (margin = "0px") => {
const [isIntersecting, setIsIntersecting] = useState(false);

const observerRef = useRef(null);

useEffect(() => {
const observer = new IntersectionObserver(
([entry]) => {
Expand All @@ -14,13 +12,12 @@ export const useInterectionObserver = (margin = "0px") => {
{ rootMargin: margin }
);
observer.observe(observerRef.current);

return () => observer.disconnect();
}, [margin]);

return { isIntersecting, observerRef };
};

useInterectionObserver.propTypes = {
isVisible: PropTypes.string,

useIntersectionObserver.propTypes = {
isVisible: PropTypes.string,
};