react-wizard-flow
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

react-wizard-flow

npm downloads gzip size npm version PRs Welcome

Usage

import { createWizardFlow, useWizardFlow } from 'react-wizard-flow';

enum TestSteps {
  step1,
  step2,
}

const WizardFlow = createWizardFlow(TestSteps);

function Step1() {
  const { transition, close } = useWizardFlow(WizardFlow);
  return (
    <div>
      <header>Step 1</header>
      <button onClick={() => transition(TestSteps.step1)}>To Step 1</button>
      <button onClick={() => transition(TestSteps.step2)}>To Step 2</button>
      <button onClick={close}>Close</button>
    </div>
  );
}

function Step2() {
  const { transition, close } = useWizardFlow(WizardFlow);
  return (
    <div>
      <header>Step 1</header>
      <button onClick={() => transition(TestSteps.step1)}>To Step 1</button>
      <button onClick={() => transition(TestSteps.step2)}>To Step 2</button>
      <button onClick={close}>Close</button>
    </div>
  );
}

const STEPS = {
  [TestSteps.step1]: <Step1 />,
  [TestSteps.step2]: <Step2 />,
};

export default function() {
  const onClose = () => { console.log('Flow closed'); }
  return <WizardFlow.Provider initialStep={TestSteps.step1} steps={STEPS} onClose={onClose} />
}

This README was generated by anansi.

Readme

Keywords

Package Sidebar

Install

npm i react-wizard-flow

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

19 kB

Total Files

18

Last publish

Collaborators

  • notwillk