@kaliber/use-render-on-mount

1.0.4 • Public • Published

useRenderOnMount

Returns a boolean indicating whether a component is mounted, so you can render on mount.

Motivation

In some cases you don't want to render a component universally, but rather only on the client. This hook provides a boolean indicating whether a component is mounted, which you can use to conditionally render the component.

When the boolean is flipped, a re-render happens so you can update your UI accordingly.

Installation

yarn add @kaliber/use-render-on-mount

Usage

import { useRenderOnMount } from '@kaliber/use-render-on-mount'

function Component() {
  const isMounted = useRenderOnMount()
  return isMounted && '😎'
}

Disclaimer

This library is intended for internal use, we provide no support, use at your own risk. It does not import React, but expects it to be provided, which @kaliber/build can handle for you.

This library is not transpiled.

Readme

Keywords

Package Sidebar

Install

npm i @kaliber/use-render-on-mount

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

2.94 kB

Total Files

6

Last publish

Collaborators

  • melissabos18
  • janbru
  • albertkaliber
  • jerryduijm
  • hjsielcken
  • kaliber-owner
  • daveykropf
  • eecolor
  • larsvankleef