npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react_js_coundown_helper

v1.1.6

Published

This packages is meant to simplify date counter events

Downloads

7

Readme

React JS Countdown Helper

The react_js_countdown_helper package is a collection of React hooks and components designed to simplify the implementation of countdown timers in React applications. With this package, you can easily create countdown timers that display the time remaining until a specified date or deadline. Features

- Customizable Countdown Timer: Create countdown timers with customizable formats and intervals.
- Pause and Resume Functionality: Pause and resume countdown timers as needed.
- Time Zone Conversion: Convert countdown timers to different time zones with ease.
- Flexible and Lightweight: Simple API for easy integration into React applications.

Installation

You can install the react_js_countdown_helper package via npm or yarn:

npm install react_js_countdown_helper

or

yarn add react_js_countdown_helper

Usage

Countdown Timer Hook

The useCountDownTarget hook allows you to create countdown timers in your components. Here's an example of how to use it:


import React from 'react';
import { useCountDownTarget } from 'react_js_countdown_helper';

const MyComponent = () => {
  const deadline = new Date('2022-12-31T23:59:59');
  const [seconds, minutes, hours, days] = useCountDownTarget(deadline);

  return (
    <div>
      <p>Time Left:</p>
      <p>{days} Days</p>
      <p>{hours} Hours</p>
      <p>{minutes} Minutes</p>
      <p>{seconds} Seconds</p>
    </div>
  );
};

Countdown Timer Component

The CountdownTimer component provides a pre-styled countdown timer that you can easily integrate into your React application. Here's an example:


import React from 'react';
import { CountdownTimer } from 'react_js_countdown_helper';

const MyComponent = () => {
  return (
    <div>
      <CountdownTimer deadline={new Date('2022-12-31T23:59:59')} />
    </div>
  );
};

Or if you need to use your own styles, you can always use a hook.

const [seconds, minutes, hours, days] = useCountdownTarget(TargetDate, true);

Documentation

Countdown Timer Hook

The useCountDownTarget hook is the core functionality of the react_js_countdown_helper package. It allows you to create countdown timers in your components. Here's how it works:

  • Inputs: It takes several parameters:

    • date: The target date or deadline for the countdown timer.
    • overflowValues (optional): A boolean flag indicating whether to display overflow values for days and hours. Default is false.
    • intervalTimer (optional): The interval at which the countdown timer updates, in milliseconds. Default is 1000 (1 second).
    • ref (optional): A React mutable ref object that can be used to pause and resume the countdown timer.
  • Outputs: It returns an array containing the time remaining until the target date, broken down into seconds, minutes, hours, and days.

Here's an example of how to use it:

import React from 'react';
import { useCountDownTarget } from 'react_js_countdown_helper';

const MyComponent = () => {
  const deadline = new Date('2022-12-31T23:59:59');
  const [seconds, minutes, hours, days] = useCountDownTarget(deadline);

  return (
    <div>
      <p>Time Left:</p>
      <p>{days} Days</p>
      <p>{hours} Hours</p>
      <p>{minutes} Minutes</p>
      <p>{seconds} Seconds</p>
    </div>
  );
};

Countdown Timer Component

The CountdownTimer component provides a pre-styled countdown timer that you can easily integrate into your React application. It internally uses the useCountDownTarget hook to manage the countdown logic. Here's how to use it:

Props: It accepts the following props:
    deadline: The target date or deadline for the countdown timer.

Here's an example of how to use it:


import React from 'react';
import { CountdownTimer } from 'react_js_countdown_helper';

const MyComponent = () => {
  return (
    <div>
      <CountdownTimer deadline={new Date('2022-12-31T23:59:59')} />
    </div>
  );
};

Contributing

Contributions are welcome! If you have any ideas, bug fixes, or enhancements, please submit a pull request or open an issue on GitHub. License

This package is open source and available under the MIT License.