Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-timer-hooks

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-native-timer-hooks

simple hooks for timer

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Github: samuel-rl

ssamuel_rl

Install

npm install react-native-timer-hooks

Example

image

Import

import { useClock } from 'react-native-timer-hooks';

Usage

import React from "react";
import { StyleSheet, View, Text, Button } from 'react-native';
import { useClock } from 'react-native-timer-hooks';

const Example = () => {
  const [counter, start, pause, reset, isRunning] = useClock({
    from: 0,
    to: 60,
    stopOnFinish: true,
  });

  return (
    <View style={styles.container}>
      <Text>Seconds: {counter}</Text>
      <Button
        onPress={() => {
          isRunning ? pause() : start();
        }}
        title={isRunning ? 'Pause' : 'Start'}
      />
      <Button onPress={() => reset()} title={'reset'} />
    </View>
  );
};

The useClock hooks has the following parameters:

NameTypeExplanationRequiredDefault Value
fromnumberThe initial value of counter.undefined
tonumberWhen the timer should stop. undefined
msnumberThe number of millisecond between.
1000ms for 1 second.
1000
downbooleanCounter value should decrease or increase.false

The useClock hooks has the following returns values:

NameTypeExplanationParameters
counternumberThe initial value of counter.
startfunctionStart the counter.
pausefunctionPause the counter.
resetfunctionReset the counter. There is an optional parameter to set the from valuefrom:number = the restart value of the counter.
isRunningbooleanReturn true if the counter is running, false if not.

License

MIT

Keywords

FAQs

Package last updated on 07 Nov 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc