JS - Breakpoints var in react

0 votes
180 views
added Apr 5, 2023 in React by lcjr First Warrant Officer (11,790 points)
const getImageSize = () => {
  const windowSize = window.screen.width;

  if (windowSize < 414) return '300x500';
  if (windowSize < 768) return '414x690';
  if (windowSize < 1024) return '700x404';
  return '780x450';
};

const getFeaturedImage = () => {
  if (!featuredSto) return undefined;
  return `https://aaa.com/s3fs-public/aaa-folder/${
    featuredSto?.artwork_key
  }${getImageSize()}px.jpg`;
};

 

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