Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: containerRef.current.firstChild is null #19

Open
jrichardsz opened this issue Sep 22, 2021 · 0 comments
Open

TypeError: containerRef.current.firstChild is null #19

jrichardsz opened this issue Sep 22, 2021 · 0 comments

Comments

@jrichardsz
Copy link

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) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant