Skip to content

Commit 0d51105

Browse files
committed
container ref
1 parent bdecf72 commit 0d51105

File tree

1 file changed

+4
-3
lines changed
  • src/components/StartWithEthereumFlow

1 file changed

+4
-3
lines changed

src/components/StartWithEthereumFlow/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const StartWithEthereumFlow = ({
1616
newToCryptoWallets: Wallet[]
1717
}) => {
1818
const swiperRef = useRef<SwiperRef>(null)
19+
const containerRef = useRef<HTMLDivElement>(null)
1920
const [activeIndex, setActiveIndex] = useState(1)
2021
const [totalSlides, setTotalSlides] = useState(0)
2122
const [slideHeights, setSlideHeights] = useState<number[]>([])
@@ -50,10 +51,9 @@ const StartWithEthereumFlow = ({
5051

5152
const handleNext = () => {
5253
swiperRef.current?.swiper.slideNext()
53-
const container = document.getElementById("start-with-ethereum-flow")
5454

55-
if (container) {
56-
const containerRect = container.getBoundingClientRect()
55+
if (containerRef.current) {
56+
const containerRect = containerRef.current.getBoundingClientRect()
5757
window.scrollTo({
5858
top: window.scrollY + containerRect.top - 90,
5959
behavior: "smooth",
@@ -63,6 +63,7 @@ const StartWithEthereumFlow = ({
6363

6464
return (
6565
<SwiperContainer
66+
ref={containerRef}
6667
className={cn(
6768
"-mx-8",
6869
"w-screen",

0 commit comments

Comments
 (0)