ridhwaans / homehost

self-hosted, Netflix-like app made for streaming

Home Page:homehost.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: containerRef.current.firstChild is null

jrichardsz opened this issue · comments

If I mapping just the videos and tv shows I get this error when I try to access to the portal:

TypeError: containerRef.current.firstChild is null
useSlider/<
src/hooks/useSlide.js:25

  22 | if (containerRef.current && data) {
  23 | 
  24 |     const containerWidth = containerRef.current.clientWidth;
> 25 |     const itemWidth = containerRef.current.firstChild.clientWidth
     | ^  26 |     const totalInViewport = Math.ceil(containerWidth / itemWidth)
  27 | 
  28 |     setSlider(containerRef.current.children)

Movies/</<
src/components/Movies/index.js:43

  40 |     setRecentlyAddedMovies(response.recentlyAddedMovies)
  41 |     setPopularMovies(response.popularMovies)
  42 |     setAnimationMovies(response.animationMovies)
> 43 |     setHighestRatedMovies(response.highestRatedMovies)
     | ^  44 |     setWarMovies(response.warMovies)
  45 | 
  46 | })

Temp fix

Modify this line in the client to render just not null data

if (containerRef.current && containerRef.current.firstChild && data) {