Where To Put The Braces React Code

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 (
         <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>
 } else {
    return null;


the order of opening and closing () vs {} doesn’t match

I did not add the 3 braces in my example because I don’t know where to put them. Without the useImperativeHandle(ref, () => ({ there is no error in my editor.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.