JSPM

react-sequence-wrapper

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

a higher order component decorator providing state management for components that use a sequence of steps, like wizards and other multiple-step user interfaces.

Package Exports

  • react-sequence-wrapper

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-sequence-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-sequence-wrapper

a higher order component decorator providing state management for components that use a sequence of steps, like wizards and other multiple-step user interfaces.

npm

Installation

npm install react-sequence-wrapper --save-dev

Usage

Here's an example of using sequence decorator with the steps option to wrap a component and provide it with props to implement a basic wizard with forward and backwards navigation.

import React, { Component } from "react";
import { Label, Button } from "react-bootstrap";
import sequence from "./react-sequence-wrapper";

@sequence({
  steps: ["Greet", "Compliment", "Leave"]
})
export default class BasicWizard extends Component {

  render() {
    const {
      currentStepIndex,
      currentStep,
      nextStep,
      prevStep,
      setStepIndex,
      setStep,
      isFirstStep,
      isLastStep,
      steps
    } = this.props; //all provided by @sequence

    const stepComponents = [
      <div>hello world!</div>,
      <div>nice shirt!</div>,
      <div>goodbye!</div>
    ];

    return (
      <div>
        <h2>
          <Label>
            {currentStepIndex + 1}. {currentStep}
          </Label>
        </h2>

        <div>
          {stepComponents[currentStepIndex]}

          <div id="navigation">
            <Button onClick={prevStep} disabled={isFirstStep}>
              Back
            </Button>
            <Button onClick={nextStep} disabled={isLastStep}>
              Next
            </Button>
          </div>
        </div>
      </div>
    );
  }
}

Dev Dependencies

License

MIT