npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-form-management

v1.1.9

Published

React form management for React

Downloads

28

Readme

React Form Management

React Form Management is used to handle the state to render only itself, preventing page lagging or freezing and validating user-inputted data. Demo

Features

  • To manage the state to protect the UI lags.
  • validation form (yup)

Installation

npm install react-form-management
yarn add react-form-management

QuickStart

import { FormProvider, Form, useFormManagement } from "react-form-management";
import * as yup from "yup";

const App = () => {
  const { onSubmit, onReset, form, errors, formProvider } = useFormManagement({
    defaultForm: {
      first_name: "",
      last_name: ""
    },
    schema: yup.object().shape({
      first_name: yup.string().required(),
      last_name: yup.string().required()
    })
  });

  const onClickSubmit = ({ form }) => {
    console.log("form", form);
  };

  return (
    <FormProvider formProvider={formProvider}>
      <Form
        name="first_name"
        render={({ formState, errorState }) => {
          return (
            <div>
              <input value={formState.value} onChange={formState.onChange} />
              {errorState.isError && errorState.errorMessage}
            </div>
          );
        }}
      />
      <Form
        name="last_name"
        render={({ formState, errorState }) => {
          return (
            <div>
              <input value={formState.value} onChange={formState.onChange} />
              {errorState.isError && errorState.errorMessage}
            </div>
          );
        }}
      />
      <button onClick={() => onSubmit(onClickSubmit)}>Submit</button>
      <button onClick={() => onReset({})}>Reset</button>
    </FormProvider>
  );
};
export default App;

API useFormManagement

| Parameter | Type | Description | | :------------ | :------- | :------------------------- | | formProvider | object | To send the data to the formProvider. | | form | object | Your form value | | errors. | object | Form errors according to the schema you have declared. | | onSubmit | function | Submit form | | onReset | function | Reset Form | | onChangeCustom | function | this function use for change other field value | | observe | function | listen value when the value is changed | | addItem | function | this function use for add new item in the case of an array | | removeItem | function | this function use for remove item in the case of an array | | removeAllItem | function | this function use for remove all item in the case of an array |

Props useFormManagement

| Parameter | Type | Description | | :------------ | :------- | :------------------------- | | defaultForm | object | Default form value | | schema | yup | Schema for validate form error |

Props FormProvider

| Parameter | Type | Description | | :------------ | :------- | :------------------------- | | formProvider | object | Required |

Props Form

| Parameter | Type | Description | Method | | :------------ | :------- | :------------------------- | :----------------------| | name | string | Required Your field name | | | render | component | Required Your component input | render={ ({ formState, errorState, observe }) => {} } OR render={ ({ formState: { value, onChange, onChangeCustom }, errorState: { isError, errorMessage }, observe }) => {} } |