2.0.0 • Published 2 years ago

react-native-timer-hooks v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Install

npm install react-native-timer-hooks

Example


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:

The useClock hooks has the following returns values:


License

MIT