// wrap the return<> inside the function function functionWrapper() { const facebook = () => { window.open( `http://facebook.com/sharer.php?u=${window.location.href}`, '_blank', ); }; return ( <> // your content goes here </> ); }