0

I was trying to run this but its showing this error -

Error: Objects are not valid as a React child (found: object with keys {adult, backdrop_path, genre_ids, id, original_language, original_title, overview, popularity, poster_path, release_date, title, video, vote_average, vote_count}).  

also used another same type of useEffect function and didnt get the error i.e

 useEffect(() => {
   fetch(
     `https://api.themoviedb.org/3/search/movie?api_key=${process.env.REACT_APP_TMDB_KEY}&language=en-US&include_adult=false&query=${query}&page=${pageNumber}`
    )
      .then((res) => res.json())
      .then((data) => {
        if (!data.errors) {
          setResults(data.results);
        } else {
          console.log("error");
          setResults([]);
        }
      });
  }, [pageNumber, query]);

useEffect(() => {
    fetch(
      `https://api.themoviedb.org/3/discover/movie?api_key=${process.env.REACT_APP_TMDB_KEY}&language=en-US&include_adult=false&page=${pageNumber}&with_genres=${selected}`
    )
      .then((res) => res.json())
      .then((data) => {
        if (!data.errors) {
          let res = data.results
          setCategoryContent(res);
        } else {
          console.log("error");
          setCategoryContent([]);
        }
      });
  }, [pageNumber, selected]);
Abe
  • 4,500
  • 2
  • 11
  • 25
  • Does this answer your question? [Invariant Violation: Objects are not valid as a React child](https://stackoverflow.com/questions/33117449/invariant-violation-objects-are-not-valid-as-a-react-child) – Abe Aug 04 '23 at 04:54
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 04 '23 at 10:29

0 Answers0