1.0.4 • Published 4 years ago

@kaliber/use-render-on-mount v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

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 && '😎'
}

npm.io

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.

1.0.4

4 years ago

1.0.2

5 years ago

1.0.3

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago