import { useState, useRef, forwardRef } from "react";
import "./ScrollToNextSection.css";
const ScrollToNextSection = forwardRef(({ visibleSection }, ref) => {
const scrollToSection = () => {
const currentIndex = ref.current.findIndex(
(sectionRef) => sectionRef && sectionRef.id === visibleSection
);
const nextSection = ref.current[currentIndex + 1];
if (nextSection) {
nextSection.scrollIntoView({ behavior: "smooth" });
} else if (ref.current[0]) {
ref.current[0].scrollIntoView({ behavior: "smooth" });
}
};
return (
<button onClick={scrollToSection} className="scroll-btn">
Вниз
</button>
);
});
export default ScrollToNextSection;
Bearer {Token}