useInView call for each component: Why do all return 'true' once the first element is in view? #540
Answered
by
thebuilder
bartonyoung
asked this question in
Q&A
|
My home page loads multiple large components that I want to delay rendering until they are in view. I am lazy loading the components, and make a call to useInView() once per component, giving each their own ref. However, once the first component comes into view, all of the other component chunks load as well. Am I doing something wrong? Attached is a gist of the code. https://gist.github.com/bartonyoung/e1457f9414891f90edba17cf7e1765d7 |
Answered by
thebuilder
Apr 12, 2022
Replies: 1 comment 1 reply
|
Not sure what the components are doing. But most likely is your styling that causes all the components to start inside the viewport. Are you just rendering an empty |
1 reply
Answer selected by
bartonyoung
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure what the components are doing. But most likely is your styling that causes all the components to start inside the viewport. Are you just rendering an empty
‹div›with your ref, until they come into view?