DEMO
Not Yet Mounted

useHasMounted

Hook that returns whether or not the component has mounted. Useful in SSR frameworks like Next or Gatsby.

Usage

import { useHasMounted } from '@react-hooks-library/core'

export function Demo() {
  const hasMounted = useHasMounted()

  return (
    <div className={`pill ${hasMounted ? 'success' : 'danger'}`}>
      {hasMounted ? 'Mounted' : 'Not Yet Mounted'}
    </div>
  )
}

Type Declarations

/**
 * Hook that returns whether or not the component has mounted.
 * Useful in SSR frameworks like Next or Gatsby.
 *
 * @returns hasMounted
 */
declare function useHasMounted(): boolean

Source

Source | Demo | Docs