Neighborly Package Megalodon

    @asosunoff/react_use_form
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0 • Public • Published

    React-Use-Form component React

    Table

    Demo:

    https://asosunoff.github.io/React-Use-Form/

    Install component

    npm i @asosunoff/react_use_form

    Launch project:

    git clone https://github.com/aSosunoff/React-Use-Form.git
    cd React-Use-Form
    npm i
    npm run start
    

    Test project:

    npm test
    

    Example

    import { useForm, InitialForm } from "@asosunoff/react_use_form";
    
    const INITIAL_FORM: InitialForm<"email"> = {
      email: {
        value: "",
        validation: (value) => {
          if (is.not.email(value)) {
            return {
              errorMessage: "Не правильно введён email",
            };
          }
        },
      },
    };
    
    const App = () => {
      const {
        values,
        handlers: { email },
        isInvalidForm,
        resetHandler,
        setValue,
        setValues,
      } = useForm(INITIAL_FORM);
    
      return (
        <form>
          <div>
            <Input
              label="Email"
              value={email.value}
              onChange={email.onChange}
              invalid={email.touched && email.invalid}
              invalidMessage={email.invalidMessage}
            />
          </div>
        </form>
      );
    };

    Install

    npm i @asosunoff/react_use_form

    DownloadsWeekly Downloads

    23

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    60.1 kB

    Total Files

    21

    Last publish

    Collaborators

    • asosunoff