How to use the ahooks.useEventListener function in ahooks

To help you get started, we’ve selected a few ahooks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pingcap / tidb-dashboard / ui / dashboardApp / layout / main / Sider / index.tsx View on Github external
function useActiveAppId(registry) {
  const [appId, set] = useState('')
  useEventListener('single-spa:routing-event', () => {
    const activeApp = registry.getActiveApp()
    if (activeApp) {
      set(activeApp.id)
    }
  })
  return appId
}
github pingcap / tidb-dashboard / ui / lib / components / AppearAnimate / index.tsx View on Github external
function AppearAnimate({
  className,
  motionName,
  children,
}: IAppearAnimateProps) {
  const [isFirst, setIsFirst] = useState(true)

  const handleAnimationEnd = useCallback(() => {
    setIsFirst(false)
  }, [])

  const ref = useRef(null)
  useEventListener('animationend', handleAnimationEnd, { target: ref })

  return (
    <div>
      {children}
    </div>
  )
}