RUI.next

Hooks
useLatest

useLatest

A hook that returns the latest value, that could avoid the closure problem.

const latestValueRef = useLatest<T>(value: T): MutableRefObject<T>;
const latestValueRef = useLatest<T>(value: T): MutableRefObject<T>;

Example

Basic usage of useLatest hook.

Count by useState: 0
Count by useLatest: 0

Start testing

API

PropertyDescriptionTypeDefault
---