New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-element-timer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-element-timer

A component that displays a timer and countdown for React Native.

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
176
decreased by-16.19%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-element-timer

A component that displays a timer and countdown for React Native. Implemented using react-native-background-timer

Getting started

    npm install react-native-element-timer --save

or

    yarn add react-native-element-timer
Demo

Timer Props
PropsTypeisRequireDescription
initialSecondsNumberNoInitial seconds, defalut is 0
autoStartBooleanNoAuto start timer
startref.start()YesStart timer
pauseref.pause()YesPause timer
resumeref.resume()YesResume timer
stopref.stop()YesStop timer
styleViewStyleNoStyling container view
fontFamilyStringNoCustomize font style
textStyleTextStyleNoStyling text
formatTimehh:mm:ss or ssNoFormat time
onTimes(seconds) => voidNocallback when running time
onPause(seconds) => voidNoCallback when the pause event is called
onEnd(seconds) => voidNoCallback when the stop event is called
Countdown Props
PropsTypeisRequiredefault
initialSecondsNumberYesInitial seconds
autoStartBooleanNoAuto start timer
startref.start()YesStart timer
pauseref.pause()YesPause timer
resumeref.resume()YesResume timer
stopref.stop()YesStop timer
styleViewStyleNoStyling container view
fontFamilyStringNoCustomize font style
textStyleTextStyleNoStyling text
formatTimehh:mm:ss or ssNoFormat time
onTimes(seconds) => voidNocallback when running time
onPause(seconds) => voidNoCallback when the pause event is called
onEnd(seconds) => voidNoCallback when the stop event is called

Usage

    import React, {useRef} from 'react';
    import {StyleSheet, Button, Text, SafeAreaView} from 'react-native';
    import {Timer, Countdown} from 'react-native-element-timer';

    const TimerScreen = _props => {
        const timerRef = useRef(null);
        const countdownRef = useRef(null);

        return (
            <SafeAreaView style={styles.container}>
                <Text style={styles.text}>Timer:</Text>
                <Timer
                    ref={timerRef}
                    style={styles.timer}
                    textStyle={styles.timerText}
                    onTimes={e => {}}
                    onPause={e => {}}
                    onEnd={e => {}}
                />
                <Button
                    style={styles.button}
                    title={'Start'}
                    onPress={() => {
                        timerRef.current.start();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Pause'}
                    onPress={() => {
                        timerRef.current.pause();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Resume'}
                    onPress={() => {
                        timerRef.current.resume();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Stop'}
                    onPress={() => {
                        timerRef.current.stop();
                    }}
                />

                <Text style={styles.text}>Countdown:</Text>
                <Countdown
                    ref={countdownRef}
                    style={styles.timer}
                    textStyle={styles.timerText}
                    initialSeconds={5}
                    onTimes={e => {}}
                    onPause={e => {}}
                    onEnd={(e) => {}}
                />
                <Button
                    style={styles.button}
                    title={'Start'}
                    onPress={() => {
                        countdownRef.current.start();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Pause'}
                    onPress={() => {
                        countdownRef.current.pause();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Resume'}
                    onPress={() => {
                        countdownRef.current.resume();
                    }}
                />
                <Button
                    style={styles.button}
                    title={'Stop'}
                    onPress={() => {
                        countdownRef.current.stop();
                    }}
                />
            </SafeAreaView>
        );
    };

    export default TimerScreen;

    const styles = StyleSheet.create({
        container: {
            flex: 1,
            alignItems: 'center',
            padding: 20,
        },
        text: {
            fontWeight: 'bold',
            fontSize: 16,
            marginTop: 40,
        },
        timer: {
            marginVertical: 10,
        },
        timerText: {
            fontSize: 20,
        },
        button: {
            marginVertical: 5,
            backgroundColor: 'white',
            borderRadius: 24,
            width: 100,
        },
    });

Donate

Support maintainers with a donation and help them continue with activities.


fateh999




Keywords

FAQs

Package last updated on 21 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