Skip to content

Commit

Permalink
feat(Channel): Refactor ChannelCarousel to use useNativeEventListener…
Browse files Browse the repository at this point in the history
… for window resize
  • Loading branch information
Kechicode committed Jan 3, 2025
1 parent 015c0cd commit 8c9868e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/views/Home/Channel/Page/Carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
useState,
} from 'react'

import { useNativeEventListener } from '~/components'

// import { useCarousel } from '~/components/Hook/useCarousel'
import Dot from './Dot'
import styles from './styles.module.css'
Expand Down Expand Up @@ -167,7 +169,7 @@ const ChannelCarousel = () => {

const [columnCount, setColumnCount] = useState<ColumnCount>('4')

useEffect(() => {
useNativeEventListener('resize', () => {
if (typeof window !== 'undefined') {
if (window.innerWidth >= 453) {
setColumnCount('5')
Expand All @@ -179,7 +181,7 @@ const ChannelCarousel = () => {
setColumnCount('7')
}
}
}, [])
})

const pageCount = Math.ceil(items.length / (Number(columnCount) * 2))
let slicedItems = []
Expand Down

0 comments on commit 8c9868e

Please sign in to comment.