by
0
4
6,857
11
Top 1% !
Popular
Pearl of Wisdom
Specified
Popularity: 924th place
No tags for this snippet yet.
LanguageJavaScript
LicenseMIT_X11
SourceGitHub

A simple countdown timer example in ES6, React and Reflux.

A simple countdown timer example in ES6, React and Reflux.: 
timer.jsx
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/357400/A-simple-countdown-timer-example-in-ES6-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
import React from 'react' import Reflux from 'reflux' var TimeActions = Reflux.createActions(['tick']) var TimeStore = Reflux.createStore({ listenables: [TimeActions], onTick: function(tick) { this.trigger(tick); if (tick === 0) return; setTimeout(() => TimeActions.tick(tick - 1), 1000); } }) var Watch = React.createClass({ mixins: [Reflux.connect(TimeStore, 'tick')], componentDidMount: function() { TimeActions.tick(this.props.ticks) }, render: function() { return ( <h1>{this.state.tick}</h1> ) } }) React.render(<Watch ticks={10}></Watch>, document.body); export default {}
If you want to be updated about similar snippets, Sign in and follow our Channels