import { useCallback , MouseEvent } from 'react' ; import type { ComponentProps } from 'react' ; import constants from 'utils/constants' ; import FloatButton from 'components/FloatButton' ; type Props = { hashtags : string ; } ; type ButtonProps = ComponentProps < typeof FloatButton > ; const useTweet = ( { hashtags } ) => { const onTweet = useCallback ( ( event ) => { event . preventDefault ( ) ; const twitterURL = `https://twitter.com/share?ref_src=twsrc%5Etfw/&hashtags=${ hashtags }` ; window . open ( twitterURL , 'twitter' ) ; } , [ hashtags ] ) ; const tweetButtonProps = { onClick : onTweet , text : constants . tweet , title : constants . twitter , type : 'twitter' , } ; return { TweetButton : FloatButton , tweetButtonProps } ; } ; export default useTweet ;