useLastUpdated

一个 React 钩子(Hook),用于记录状态的最后更新时间。

演示

源码
Count:
0 (Not update yet)
Other:
0 (Not update yet)

用法

请查看 API。

源码

点击下方链接跳转 GitHub 查看源代码。

API

const lastUpdated = useLastUpdated(source, options)

源码

你想要记录最后更新时间的任何状态。

选项 Options

export type UseLastChangedOptions = {
  /**
   * 最后更新时间戳的初始值。
   *
   * @defaultValue null
   */
  initialValue?: number | null
  /**
   * 如果为 `true`,则深度比较源对象。
   *
   * @defaultValue false
   */
  deep?: boolean
}

返回值

number | null

当源被更新时,数字将更新为当前的时间戳,否则它将是 null(例如,源 被更新)。