🚀 DAY 1 OF LAUNCH WEEK: Reachability for Ruby Now in Beta.Learn more →
Socket
Book a DemoInstallSign in
Socket

@rhc-shared-components/scroll-to-error

Package Overview
Dependencies
Maintainers
5
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rhc-shared-components/scroll-to-error

project description

latest
npmnpm
Version
0.0.3
Version published
Maintainers
5
Created
Source

@rhc-shared-components/scroll-to-error

This scroll-to-error component can be used to scroll the page towards the first error of the form.

NPM JavaScript Style Guide

Install

npm install --save @rhc-shared-components/scroll-to-error

## Usage

```tsx
import React from 'react';
import { Form, Formik } from 'formik';
import * as Yup from 'yup';
import { Title } from "@patternfly/react-core";
import { FormTextInput } from "@rhc-shared-components/form-text-input";
import { ScrollToError } from '@rhc-shared-components/scroll-to-error';

enum ExampleEnum{
  FieldName ='companyLogo'
}

export const VALIDATIONSCHEMA = () => {
  return Yup.object().shape({
  [ExampleEnum.FieldName]:
  Yup.string().required("required")
  })
}

const App = () => {
  return (
    <div>
      <Title headingLevel={'h1'}>Text Input with formik</Title>
      <Formik
        initialValues={{
          [ExampleEnum.FieldName]: 'this is a test text'
        }}
        validationSchema={VALIDATIONSCHEMA}
        enableReinitialize={true}
        onSubmit={() => {
        }}>
          <Form>
        <FormTextInput
          name={ExampleEnum.FieldName}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={ExampleEnum.FieldName}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName2"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName3"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName4"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName5"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName6"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
         <FormTextInput
          name={"FieldName7"}
          label={'helloWorld label'}
          helperText={'helloWorld helper'}
          isRequired={true}
        />
        <ScrollToError/>
        <button type="submit">Submit</button>
        </Form>
      </Formik>
    </div> );
}


export default App;

License

MIT © authorGithubUsername

FAQs

Package last updated on 14 Feb 2023

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