I have this react code
const MenuItem = ({title, imageUrl, linkUrl}) => {
const [isClicked, setIsClicked] = useState(false);
const handleClick = () =>{
setIsClicked(true);
}
const handleLocation = () => {
if(window.location.pathname === '/movie'){
<MoviePage categoryId={linkUrl}/>
}
}
return (
<div className="menu-item">
<div className="image-container" style={{backgroundImage:`url(${imageUrl})`}}/>
<div className="image-content"
onClick={handleClick}>
{isClicked ? {handleLocation}: null}
<h1>{title}</h1>
</div>
</div>
);
}
Here, on the onclick event I want to render the component on another page, so I used window.location, but getting this error
Uncaught Error: Objects are not valid as a React child (found: object with keys {handleLocation}). If you meant to render a collection of children, use an array instead.