Skip to content

hooks/useLatest

import { … } from 'zidane-ui'ui/src/hooks/useLatest.ts

Functions#

useLatestFunction#

A stable function returning value as of the last commit, for what is built once (a store, a palette source, a listener) and reads the current value when it runs. Never call it during render.

TypeScript
function useLatest<T>(value: T): () => T
Type parameters
NameDescription
T
Parameters
NameTypeDescription
valueT

What the function returns.

() => T

The same function for the component's life.

ui/src/hooks/useLatest.ts:10