New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-use-shared-tick

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-shared-tick

React hook run function in same setInterval

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

npm version

React useSharedTick

React hook run function in same setInterval

Installation

use npm

npm install react-use-shared-tick --save

use yarn

yarn add react-use-shared-tick

use pnpm

pnpm install react-use-shared-tick

Usage

run function per second

import { useStatus } from "react"
import useSharedTick from "react-use-shared-tick"

function App() {
  const [time, setTime] = useState(Date.now())
  useSharedTick(setTime)

  return (
    <div>Current Timestamp: {time}</div>
  )
}

run function per 3 second

useSharedTick(setTime, {tick: 3000})

API

useSharedTick

useSharedTick(handler: (t: number)=>void, param)

Handler

ParamTypeDescription
timestampnumbercurrent timestamp

Parameter

FieldTypeDefaultRequirementDescription
ticknumber1000NoRunning interval time
runOnTabVisiblebooleanfalseNowhen true will pause/start interval if visibilitychange event dispatched

License

The files included in this repository are licensed under the MIT license.

FAQs

Package last updated on 02 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts