New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

step-wizard-react-hook

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

step-wizard-react-hook

This is an attempt to create a form that validates as the user goes through each step. For now, it's most useful if you want to split the form but still have validation.

latest
Source
npmnpm
Version
0.3.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Step Wizard for React Hook Form

This is an attempt to create a form that validates as the user goes through each step. For now, it's most useful if you want to split the form but still have validation.

Install

yarn add step-wizard-react-hook react-hook-form @hookform/resolvers yup

Code Example

import React from 'react';

import { StepWizardWrapper, StepWizardTab } from 'step-wizard-react-hook';

const MyStepWizard = StepWizardWrapper(<TabComponent />);

export const App = () => {
    return (
        <MyStepWizard onSubmit={(data) => console.log(data)}>
            <StepWizardTab name="Step 1">
                <p>Step 1</p>
            </StepWizardTab>

            <StepWizardTab name="Step 2">
                <p>Step 2</p>
            </StepWizardTab>

            <StepWizardTab name="Step 3">
                <p>Step 3</p>
            </StepWizardTab>
        </MyStepWizard>
    );
};

StepWizardWrapper

StepWizardWrapper needs to be called with the layout component inside so that it becomes StepWizardProvider. The Provider has the following properties and extends react-hook-form UseFormProps.

KeyTypeRequiredDescription
onSubmitSubmitHandler<FormValues>trueOn submit event for the last step.
aditionalData{ [key: string]: any }falseAny additional data you want to provide in case you don't want to use another Context.
childrenReact.ReactNodetrueTabs indicating each step of the form.

StepWizardTab

This component is used to help the lib gather important information regarding each step.

KeyTypeRequiredDescription
idstringfalseCreate a unique identifier if needed.
namestring or React.ReactNodetrueName for the layout tab bar.
validationSchemaanyfalseYup validation schema for the step.
childrenReact.ReactNodetrueTab UI component for the form step.

useStepWizard

This is the step wizard context containing the following data.

KeyTypeDescription
formRefReact.RefObject<HTMLFormElement>Reference to the wrapper form
tabsStepWizardTabProps[]List of all children tabs props.
stepnumberCurrent step.
currentTabStepWizardTabPropsCurrent step tab.
aditionalData{ [key: string]: any }Additional Data passed through Provider.
gotoStep(newStep?: number) => voidGo to a specific step.
nextStep() => voidGo to the next step.
previousStep() => voidGo to the previous step.

Keywords

step wizard

FAQs

Package last updated on 27 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts