Page scroller does not work correctly due to dynamic data / content

Due to the fact that I have a lot of dynamic data, it is impossible to use navigation through the Link or <a> tag after updating the page or as soon as the page is loaded for the first time. Because as soon as the user wants to click on the button that will scroll to another section for the first time, he will see that the navigation has scrolled lower than necessary. In addition, after the first scrolling of the navigation, the scroller works as it should be, and stops where it needs to, unless the page is completely refreshed.

WorkingWithSection.tsx

import { cardItems } from "@/data";
import React from "react";
import Card from "./Card";
import SectionHeader from "./UI/SectionHeader";

const WorkingWithSection = () => {
  return (
    <section id="working-with" className="mb-28">
      <SectionHeader>WorkingWith</SectionHeader>
      <div className="flex flex-col gap-y-5 md:grid md:grid-cols-2 md:gap-5 lg:grid-cols-3">
        {cardItems.map((item, index) => (
          <Card
            key={item.id}
            icon={item.icon}
            title={item.title}
            description={item.description}
            addClasses={
              index === cardItems.length - 1
                ? "md:col-span-2 lg:order-3"
                : `lg:order-${index === cardItems.length - 2 ? "4" : index}`
            }
          />
        ))}
      </div>
    </section>
  );
};

export default WorkingWithSection;

Card.tsx

import React from "react";

interface CardProps {
  title: string;
  description: string[];
  addClasses: string;
  icon: React.ElementType;
}

const Card: React.FC<CardProps> = ({
  title,
  description,
  addClasses,
  icon: Icon,
}) => {
  return (
    <article
      className={`${addClasses} transition-card group flex flex-col items-center justify-start rounded-10 border-1 border-white-100 bg-transparent px-7 py-14 text-white-100 hover:bg-white-200 hover:fill-black-100 hover:text-black-100`}
    >
      <figure className="mb-6">
        <Icon className="h-16 w-16 fill-white-100 group-hover:fill-black-100" />
      </figure>
      <h3 className="mb-6 inline text-center text-2xl font-bold">{title}</h3>
      <ul className="inline-block list-inside list-disc px-5">
        {description.map((listItem, index) => (
          <li
            key={index}
            className="transition-text list-disc text-gray-300 group-hover:text-black-100"
          >
            {listItem}
          </li>
        ))}
      </ul>
    </article>
  );
};

export default Card;


##Just Link navigation with smooth behavior

"use client";

import React, { useLayoutEffect, useState } from "react";
import { Link } from "react-scroll";

interface ButtonNavigationProps {
  navigateTo: string;
  children: React.ReactNode;
}

const ButtonNavigation: React.FC<ButtonNavigationProps> = ({
  navigateTo,
  children,
}) => {
  return (
    <Link
      smooth={true}
      spy={true}
      isDynamic={true}
      to={navigateTo}
      offset={-120}
      duration={650}
      className="flex items-center justify-center gap-x-2 px-7 py-3 font-medium"
    >
      {children}
      <svg
        xmlns="http://www.w3.org/2000/svg"
        height="24"
        viewBox="0 -960 960 960"
        width="24"
        fill="currentColor"
      >
        <path d="m560-240-56-58 142-142H160v-80h486L504-662l56-58 240 240-240 240Z" />
      </svg>
    </Link>
  );
};

export default ButtonNavigation;

d

Most likely, this is the fault of the dynamic content of other sections, because when I comment on these dynamic sections, the scrolling works correctly. I also tried to use useLayoutEffect, but I hadn’t have good result(Maybe I did something incorrectly with this hook)

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Page scroller does not work correctly due to dynamic data / content

Due to the fact that I have a lot of dynamic data, it is impossible to use navigation through the Link or <a> tag after updating the page or as soon as the page is loaded for the first time. Because as soon as the user wants to click on the button that will scroll to another section for the first time, he will see that the navigation has scrolled lower than necessary. In addition, after the first scrolling of the navigation, the scroller works as it should be, and stops where it needs to, unless the page is completely refreshed.

WorkingWithSection.tsx

import { cardItems } from "@/data";
import React from "react";
import Card from "./Card";
import SectionHeader from "./UI/SectionHeader";

const WorkingWithSection = () => {
  return (
    <section id="working-with" className="mb-28">
      <SectionHeader>WorkingWith</SectionHeader>
      <div className="flex flex-col gap-y-5 md:grid md:grid-cols-2 md:gap-5 lg:grid-cols-3">
        {cardItems.map((item, index) => (
          <Card
            key={item.id}
            icon={item.icon}
            title={item.title}
            description={item.description}
            addClasses={
              index === cardItems.length - 1
                ? "md:col-span-2 lg:order-3"
                : `lg:order-${index === cardItems.length - 2 ? "4" : index}`
            }
          />
        ))}
      </div>
    </section>
  );
};

export default WorkingWithSection;

Card.tsx

import React from "react";

interface CardProps {
  title: string;
  description: string[];
  addClasses: string;
  icon: React.ElementType;
}

const Card: React.FC<CardProps> = ({
  title,
  description,
  addClasses,
  icon: Icon,
}) => {
  return (
    <article
      className={`${addClasses} transition-card group flex flex-col items-center justify-start rounded-10 border-1 border-white-100 bg-transparent px-7 py-14 text-white-100 hover:bg-white-200 hover:fill-black-100 hover:text-black-100`}
    >
      <figure className="mb-6">
        <Icon className="h-16 w-16 fill-white-100 group-hover:fill-black-100" />
      </figure>
      <h3 className="mb-6 inline text-center text-2xl font-bold">{title}</h3>
      <ul className="inline-block list-inside list-disc px-5">
        {description.map((listItem, index) => (
          <li
            key={index}
            className="transition-text list-disc text-gray-300 group-hover:text-black-100"
          >
            {listItem}
          </li>
        ))}
      </ul>
    </article>
  );
};

export default Card;


##Just Link navigation with smooth behavior

"use client";

import React, { useLayoutEffect, useState } from "react";
import { Link } from "react-scroll";

interface ButtonNavigationProps {
  navigateTo: string;
  children: React.ReactNode;
}

const ButtonNavigation: React.FC<ButtonNavigationProps> = ({
  navigateTo,
  children,
}) => {
  return (
    <Link
      smooth={true}
      spy={true}
      isDynamic={true}
      to={navigateTo}
      offset={-120}
      duration={650}
      className="flex items-center justify-center gap-x-2 px-7 py-3 font-medium"
    >
      {children}
      <svg
        xmlns="http://www.w3.org/2000/svg"
        height="24"
        viewBox="0 -960 960 960"
        width="24"
        fill="currentColor"
      >
        <path d="m560-240-56-58 142-142H160v-80h486L504-662l56-58 240 240-240 240Z" />
      </svg>
    </Link>
  );
};

export default ButtonNavigation;

d

Most likely, this is the fault of the dynamic content of other sections, because when I comment on these dynamic sections, the scrolling works correctly. I also tried to use useLayoutEffect, but I hadn’t have good result(Maybe I did something incorrectly with this hook)

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật