0

I don't have a HTML file. All code is written in React and JS. This is how my index.js looks like.

const Home = ({ doc, posts }) => {

if (doc && doc.data) {
    return (
      <DefaultLayout>
        <Head>
          <title>{RichText.asText(doc.data.headline)}</title>
        </Head>
        <Header
          image={doc.data.image}
          headline={doc.data.headline}
          description={doc.data.description}
        />
        <PostList posts={posts} />
      </DefaultLayout>
    );
  }

  // Message when repository has not been setup yet
  return <SetupRepo />;
};

window.addEventListener('scroll', ()=>{  
   const {scrollTop, scrollHeight, clientHeight} = document.documentElement;
   console.log({scrollTop, scrollHeight, clientHeight});
});

Here I want to run this function on window scroll.

0 Answers0