devrnt / react-use-wizard

🧙 A React wizard (stepper) builder without the hassle, powered by hooks.

Home Page:https://devrnt.github.io/react-use-wizard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Route based wizard

tommy92 opened this issue · comments

Is there any way to couple react-use-wizard with route-based views separate for each step?

Let's say I'm using Next.js and the structure would look like this:

/pages
  _app.tsx
  step1.tsx
  step2.tsx

and then:

// _app.tsx
import { Wizard } from 'react-use-wizard';

const MyApp = ({ children }) => (
  <Wizard>{children}</Wizard>
)
// step1.tsx
import { useWizard } from 'react-use-wizard';

const Step1 = () => {
  const { stepCount } = useWizard();

  console.log(stepCount) // should return 2, but actually returns 1

  return ...
}

Hi, at the moment this is not possible. Every child is treated as a step but in NextJS you can only mount one page at the time