I have a function that renders movie images and text from an API when you type into a searchbar and I am trying to add an imperativehandle but I don’t know where to put the extra braces. How do you know where to put them?
const renderedMovies = forwardRef((props, ref) => movies.map((movie) => {
useImperativeHandle(ref, () => ({
if (term.length > 0) {
return (
<div>
<img key={movie.id} src={"https://image.tmdb.org/t/p/w185/" + movie.poster_path} alt={movie.backdrop_path}/>
<h3 className='imgText'>{movie.title}</h3>
</div>
)
} else {
setMovies([]);
return null;
}}));