BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn-hooks/use-creation

use-creation

shadcn-hooks/use-creation
FreeHook

A hook to create a value only once

Install it

npx shadcn@latest add https://shadcn-hooks.com/r/use-creation.json

Source

registry/hooks/use-creation.tsshadcn-hooks.com/r/use-creation.json
1import { isEqual } from 'es-toolkit/predicate'
2import { useRef } from 'react'
3import type { DependencyList } from 'react'
4
5export function useCreation<T>(factory: () => T, deps: DependencyList) {
6 const { current } = useRef({
7 deps,
8 obj: undefined as T,
9 initialized: false,
10 })
11
12 if (current.initialized === false || !isEqual(current.deps, deps)) {
13 current.deps = deps
14 current.obj = factory()
15 current.initialized = true
16 }
17
18 return current.obj
19}

What it pulls in

npm packages

  • es-toolkit

Files it writes

  • registry/hooks/use-creation.ts

Facts

Registry
shadcn-hooks
Type
registry:hook
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-03
Last confirmed
yesterday

Go to the source

shadcn-hooks.com Debbl/shadcn-hooks on GitHub Raw registry item This item as JSON

More from shadcn-hooks

All 58 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
use-active-elementuse-active-elementshadcn-hooksHooksFreeno deps
use-batteryuse-batteryshadcn-hooksHooksFreeno deps
use-booleanuse-booleanshadcn-hooksHooksFreeno deps
use-click-any-whereuse-click-any-whereshadcn-hooksHooksFreeno deps
use-click-awayuse-click-awayshadcn-hooksHooksFreeno deps
use-clipboarduse-clipboardshadcn-hooksHooksFreeno deps
use-controllable-valueuse-controllable-valueshadcn-hooksHooksFree1 dep
use-counteruse-countershadcn-hooksHooksFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex