This has probably been asked a gazillion times before and I've looked at a hundred different places and tried a 100 different ways with more and less useEffects and returns here and there but I just can't fix it!
I'm trying to display stuff from a list of movies but cannot get it to show. I can see in logs that I do have the stuff i need in "movies" in the second useEffect but it doesnt produce any elements, I only get the wrapping div.
My code rn:
const SideScroller = ({scrollerName, titles}) => {
const [movies, setMovies] = useState([]);
const [content, setContent] = useState();
useEffect(() => {
let moviesTemp = [];
titles.forEach(title => {
async function fetchData() {
const movie = await getMovie(title);
moviesTemp.push(movie);
}
fetchData();
});
setMovies(moviesTemp);
}, [titles])
useEffect(() => {
console.log(movies)
setContent(() => {
return (
movies.map((movie) => {
console.log(movie);
return (
<div className='scrollerItem'>
<img src={movie.Poster} alt={movie.Title} />
<p>{movie.Title}</p>
</div>
);
})
);
});
}, [movies])
return (
<div className='sideScroller'>
{content}
</div>
)
}