Currently, I am in the process of developing my own single-page website using Next.js and Typescript. The site consists of two sections: one (component 1) displaying my name and three anchor elements with a 'sticky' setting for easy navigation, and another section (component 2) containing three components that are linked to by the anchor elements. My goal is to determine if each component is visible on the screen and adjust the style of the corresponding anchor element based on this information.
The main challenge I am facing and seeking help on includes:
- As the two sections are separate child components within the main 'page.tsx', how can I pass the reference information of component 2 to component 1?
- One of the components in component 2 relies on server-side actions that involve fetching data. Is there a way to use 'useEffect' to continuously monitor the view state of this component?
In my search for a solution, I came across two potential options:
- Intersection Observer
- useInview
Although I attempted to implement these solutions, I have not been able to resolve the challenges mentioned earlier, and thus, I am still struggling with this issue.