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

React Hook useEffect has a missing dependency #23

Closed
taiga-programming opened this issue Nov 18, 2020 · 1 comment · Fixed by #26
Closed

React Hook useEffect has a missing dependency #23

taiga-programming opened this issue Nov 18, 2020 · 1 comment · Fixed by #26

Comments

@taiga-programming
Copy link
Owner

I'm facing this error

1.chunk.js:6522 ./src/components/content/main-content/MainContent.js
  Line 47:6:  React Hook useEffect has a missing dependency: 'randomMovies'. Either include it or remove the dependency array  react-hooks/exhaustive-deps
printWarnings @ 1.chunk.js:6522
@taiga-programming
Copy link
Owner Author

taiga-programming commented Nov 19, 2020

solution

  • added eslint-disable-next-line
useEffect(() => {
   if (randomMovies.length) {
     const IMAGES = [
       {
         id: 1,
         url: `${IMAGE_URL}${randomMovies[0].backdrop_path}`
       },
       {
         id: 2,
         url: `${IMAGE_URL}${randomMovies[1].backdrop_path}`
       },
       {
         id: 3,
         url: `${IMAGE_URL}${randomMovies[2].backdrop_path}`
       },
       {
         id: 4,
         url: `${IMAGE_URL}${randomMovies[3].backdrop_path}`
       }
     ];
     setImages(IMAGES);
   }
   // eslint-disable-next-line
 }, []);

This article might be helpful
check

@taiga-programming taiga-programming linked a pull request Dec 17, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant