@kaliber/use-render-on-mount
v1.0.4
Published
Returns a boolean indicating whether a component is mounted, so you can render on mount.
Downloads
19
Readme
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.