useLastUpdated

A React Hook that record the last updated time of a state.

Demo

Source
Count:
0 (Not update yet)
Other:
0 (Not update yet)

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const lastUpdated = useLastUpdated(source, options)

Source

Any state that you want to record the last updated time.

Options

export type UseLastChangedOptions = { /** * The initial value of the last updated timestamp. * * @defaultValue null */ initialValue?: number | null /** * If `true`, deep compares the source object. * * @defaultValue false */ deep?: boolean }

Returns

number | null.

When the source is updated, the number will be updated to the current timestamp, otherwise it will be null (e.g. the source is NOT updated).