From aed5c6f77346dbf5e6213475f43962b051089e7c Mon Sep 17 00:00:00 2001 From: Manish Jangir Date: Mon, 28 Mar 2022 21:45:39 +0530 Subject: [PATCH] feat(current-step): passed current step index as prop in wizard component Passed current step index as prop in wizard component --- .changeset/silent-rats-own.md | 5 +++++ src/FormkWizard.tsx | 7 ++++++- src/types.tsx | 4 +++- src/useFormikWizard.tsx | 4 +++- 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 .changeset/silent-rats-own.md diff --git a/.changeset/silent-rats-own.md b/.changeset/silent-rats-own.md new file mode 100644 index 0000000..672230d --- /dev/null +++ b/.changeset/silent-rats-own.md @@ -0,0 +1,5 @@ +--- +'formik-wizard-form': minor +--- + +Passed current step index to wizard components as prop diff --git a/src/FormkWizard.tsx b/src/FormkWizard.tsx index 6870786..f3c45fb 100644 --- a/src/FormkWizard.tsx +++ b/src/FormkWizard.tsx @@ -36,7 +36,12 @@ const FormikWizard = ({ currentStepIndex, isPrevDisabled, isNextDisabled: (validateOnNext && !formikBag.isValid) || false, - renderComponent: () => , + renderComponent: () => ( + + ), }; return children({ diff --git a/src/types.tsx b/src/types.tsx index 76cfcf6..7011849 100644 --- a/src/types.tsx +++ b/src/types.tsx @@ -19,7 +19,9 @@ export type Step = { ) => Promise; /** React functional or class component */ - component: React.ComponentType>; + component: React.ComponentType< + FormikProps & { currentStepIndex: number } + >; }; export interface RenderProps extends FormikProps { diff --git a/src/useFormikWizard.tsx b/src/useFormikWizard.tsx index a51541b..bcc7432 100644 --- a/src/useFormikWizard.tsx +++ b/src/useFormikWizard.tsx @@ -34,7 +34,9 @@ const useFormikWizard = ({ currentStepIndex, isPrevDisabled, isNextDisabled: (validateOnNext && !formik.isValid) || false, - renderComponent: () => , + renderComponent: () => ( + + ), }; };