React - conditional rendering of scrollTo effect

0 votes
394 views
added Apr 16, 2021 in React by lcjr First Warrant Officer (11,990 points)
retagged Apr 19, 2021 by lcjr
const scrollToFeaturedContent = () => {
  window.scrollTo(0, scrollToRef.current.offsetTop - 54);
};

const onLordPick= () => {
  setNewsData(loadPick);
  setNewsType(0);
  if (isSticky) {
    scrollToFeaturedContent();
  }
};

 

1 Response

0 votes
responded Apr 19, 2021 by lcjr First Warrant Officer (11,990 points)
const scrollToTransactionRef = () => window.scrollTo(0, transactionRef.current.offsetTop + 460);

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...