From ed15233c31ecb96f3c160352b3584bf3c9d00127 Mon Sep 17 00:00:00 2001 From: Keith Burgie Date: Wed, 30 Oct 2019 17:29:21 -0400 Subject: [PATCH] Update README.md (#59) * Update README.md Add example of how to import and use zeroPad helper with a custom renderer. * Update README.md Shorten code block to focus only on the zeroPad function. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 42a436f..f17ad04 100644 --- a/README.md +++ b/README.md @@ -241,6 +241,14 @@ import Countdown, { zeroPad, calcTimeDelta, formatTimeDelta } from 'react-countd ### `zeroPad(value, [length = 2])` The `zeroPad` function works similar to other well-known pad-functions and takes 2 arguments into account. A `value` which can be a `string` or `number`, as well as a `length` parameter which defaults to `2` as you are most likely only going to use this function if you actually want to pad one of your values. Either returns a `number` if `length` equals `0`, or the zero-padded `string`. +```js +const renderer = ({ hours, minutes, seconds }) => ( + + {zeroPad(hours)}:{zeroPad(minutes)}:{zeroPad(seconds)} + +); +``` + ### `calcTimeDelta(date, [options])` `calcTimeDelta` calculates the time difference between a given end [`date`](#date) and the current date (`now`). It returns, similar to the [`renderer`](#renderer) callback, a custom object (also referred to as **countdown time delta object**) with the following time related data: