JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 217183
  • Score
    100M100P100Q157813F
  • License MIT

A countdown wrapper component for React

Package Exports

  • react-countdown

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-countdown) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-countdown

A countdown wrapper component for React.

Example

import React from "react";
import Countdown from "./index";


class CountdownOverlay extends React.Component {
  render() {
    return <div className="countdown">{this.props.count}</div>;
  }
}


class CountdownTestApp extends React.Component {
  constructor(props) {
    super(props);
    this.handleEnd = this.handleEnd.bind(this);
    this.handleClick = this.handleClick.bind(this);
    this.state = {
      countdownStarted: false
    };
  }

  handleEnd() {
    this.setState({countdownStarted: false});
  }

  handleClick() {
    this.setState({countdownStarted: true});
  }

  render() {
    return (
      <div>
        { this.state.countdownStarted
            ? (<Countdown onComplete={this.handleEnd}>
                <CountdownOverlay />
              </Countdown>)
            : null }
        <button onClick={this.handleClick}>
          Start Countdown
        </button>
      </div>
    );
  }
}


document.addEventListener(
  "DOMContentLoaded",
  () => {
    React.render(
      <CountdownTestApp />,
      document.getElementById("container")
    );
  }
);