import { useEffect } from "react" ; import { useEffectWhenChanged } from "coral-framework/hooks" ; import { useCoralContext } from "coral-framework/lib/bootstrap" ; import { getMessage } from "coral-framework/lib/i18n" ; param storyID param storyURL param commentCount function useCommentCountEvent ( storyID , storyURL , commentCount ) { const { eventEmitter , localeBundles } = useCoralContext ( ) ; const callback = ( ) => { eventEmitter . emit ( "commentCount" , { number : commentCount , text : getMessage ( localeBundles , "comment-count-text" , "Comment" , { count : commentCount , } ) , storyID , storyURL , } ) ; } ; useEffect ( callback , [ ] ) ; useEffectWhenChanged ( callback , [ eventEmitter , commentCount , localeBundles , storyID , storyURL , ] ) ; } export default useCommentCountEvent ;