npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cozka/react-defer-rendering

v0.5.1

Published

This package provides functionality to render components when specific conditions are met.

Readme

@cozka/react-defer-rendering

This package provides functionality to render components when specific conditions are met.

@cozka/react-defer-rendering allows you to render elements only after certain conditions are satisfied.

日本語のREADMEはこちら

Installation

npm install @cozka/react-defer-rendering

Usage

You can pass the element you want to render into a hook, and render the returned node based on the current state.

import useDeferUntilTimeout from '@cozka/react-defer-rendering/useDeferUntilTimeout';

function DeferedComponent() {
  // Renders <div>READY!</div> after 1000ms
  const { node } = useDeferUntilTimeout(<div>READY!</div>, 1000);
  return node;
}

API

Common

Options

| Property | Type | Description | | -------------------- | ----------- | ------------------------------------------------------------------------ | | pending? | ReactNode | Node to render while in the pending state | | pendingDefer? | number | Delay (in milliseconds) before rendering the pending node | | error? | ReactNode | Node to render in case of error * | | errorDefer? | number | Delay (in milliseconds) before rendering the error node * | | preserveOnceError? | boolean | If true, rendering control stops after the error node is rendered * | | readyDefer? | number | Delay (in milliseconds) before rendering the target node | | preserveOnceReady? | boolean | If true, rendering control stops after the target node is rendered |

* Only applicable for hooks that support an error state

Return Values

| Property | Type | Description | | -------- | ----------------------------------- | ------------------------------------------------------------------ | | state | 'pending' | 'ready' | error | Current state. error is returned only from hooks that support it | | node | ReactNode | The node to render based on the current state |


useDeferUntilReady(target, state, options)

Returns the appropriate node based on the current state.

Parameters

| Property | Type | Description | | ---------- | ----------------------------------- | ------------------ | | target | ReactNode | The node to render | | state | 'pending' | 'ready' | error | Current state | | options? | Common options | |

Return Value

Same as Return Values

useDeferUntilTrue(target, condition, options)

Treats true as ready and false as pending, and returns the appropriate node accordingly.
This hook does not have an error state.

Parameters

| Property | Type | Description | | ----------- | -------------------------- | ------------------ | | target | ReactNode | The node to render | | condition | boolean | Current state | | options? | Common options | |

Return Value

Same as Return Values

useDeferUntilTimeout(target, defer, options)

Returns the target node after the time specified by defer has passed.
This hook does not have an error state.

Parameters

| Property | Type | Description | | ---------- | -------------------------- | --------------------------- | | target | ReactNode | The node to render | | defer | number | Time delay before rendering | | options? | Common options | |

Return Value

Same as Return Values

useDeferUntilResolved(target, callback, options)

Returns the target node after the asynchronous function specified by callback has completed.

Parameters

| Property | Type | Description | | ---------- | -------------------------- | ----------------------------------- | | target | ReactNode | The node to be rendered | | callback | () => Promise<void> | A function that performs async work | | options? | Common options | |

Return Value

Same as Return Values

useDeferUntilFontReady(target, fontFamily, options)

Returns the target node after the specified fontFamily has been loaded.

Parameters

| Property | Type | Description | | ------------ | ----------------------------------------------- | -------------------------- | | target | ReactNode | The node to be rendered | | fontFamily | string | The font family to monitor | | options? | Common options & Additional options | |

Additional Options

| Property | Type | Description | | -------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------ | | fontVariant? | { weight?: number \| string; style?: string; stretch?: string } | Font details | | timeout? | number | Timeout duration (ms) for waiting on font load. Defaults to 4000 | | loader? | () => Promise<void> | Function to load the font |

Return Value

Same as Return Values

License

MIT License