Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/radzionc/increaser-timer

Timer with React
https://github.com/radzionc/increaser-timer

react styled-components

Last synced: 11 days ago
JSON representation

Timer with React

Awesome Lists containing this project

README

        

# increaser-timer

>

[![NPM](https://img.shields.io/npm/v/increaser-timer.svg)](https://www.npmjs.com/package/increaser-timer)

![alt text](https://cdn-images-1.medium.com/max/2000/1*FSPccrD-tfhlbniF8sJluQ.gif)

## [Demo](https://radzionc.github.io/increaser-timer/)

## Install

```bash
npm install --save increaser-timer
```

## Usage

```jsx
import React from 'react'

import Timer from 'increaser-timer'

const Container = ({ children }) => (


{children}

)

// optional
export theme = {
textColor: 'white',
timeFillColor: '#FFDC00',
circleColor: 'rgba(255, 255, 255, 0.15)'
}

class Example extends React.Component {
constructor(props) {
super(props)
const startTime = Date.now()
this.state = {
startTime,
duration: 1,
timeNow: startTime
}
setInterval(() => {
const timeNow = Date.now()
const { startTime, duration } = this.state
this.setState({ timeNow })
if (timeNow - startTime > duration * 60 * 1000) {
this.setState({ startTime: timeNow })
}
}, 500)
}

render() {
const { duration, startTime, timeNow } = this.state
return (

)
}
}
```
## [Blog Post](https://geekrodion.com/blog/timer-react)

## License

MIT © [RodionChachura](https://geekrodion.com)