1.0.12 • Published 1 year ago

react-countdown-simple v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

React <Countdown />

A simple customizable countdown component for React.

Small bundle size

Check here - https://bundlephobia.com/package/react-countdown-simple@1.0.12

Getting Started

You can install the module via npm or yarn:

npm install react-countdown-simple --save
yarn add react-countdown-simple

Examples

Here are some examples which you can try directly online.

Basic Usage

A very simple and minimal example of how to set up a countdown that counts down from 1 hour.

import React from 'react';
import ReactDOM from 'react-dom';
import Countdown from 'react-countdown-simple';

const oneHour = new Date(
  new Date().setHours(new Date().getHours() + 1)
).toISOString()

ReactDOM.render(
  <Countdown targetDate={oneHour} />,
  document.getElementById('root')
);

Live Demo

Custom renderer

import React from 'react';
import ReactDOM from 'react-dom';
import Countdown from 'react-countdown-simple';

const oneHour = new Date(
  new Date().setHours(new Date().getHours() + 1)
).toISOString()

const renderer = ({ days, hours, minutes, seconds }) =>
  <div>{days}/{hours}/{minutes}/{seconds}</div>

ReactDOM.render(
  <Countdown targetDate={oneHour} renderer={renderer}/>,
  document.getElementById('root')
);

Live Demo

Props

NameTypeDefaultDescription
targetDatestringrequiredTimestamp in the future
disableTypesbooleanfalseHide formats
formatType"d_h_m_s" | "D_H_M_S" | "dd_hh_mm_ss" | "DD_HH_MM_SS" | undefined"D_H_M_S"Predefined formats
rendererfunctionundefinedCustom renderer callback
1.0.11

1 year ago

1.0.10

1 year ago

1.0.12

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago