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

@zerry/react-formz-core

v1.10.0

Published

A small, blazing fast, intuitive form library for React. React Formz has a cozy api that let's you build forms they way you want to. With less the 10kb bundle size, React Formz boasts near constant performance regardless of how many form elements you rend

Downloads

2

Readme

React Formz 🚀

A small, blazing fast, intuitive form library for React. React Formz has a cozy api that let's you build forms they way you want to. With less the 10kb bundle size, React Formz boasts near constant performance regardless of how many form elements you render.

Build Size Version Downloads

Get started now:

npm install @zerry/react-formz immer
yarn add @zerry/react-formz immer

Visit the official website https://react-formz.zerry.dev/

Summary

React Formz is a headless (meaning it does not provide a ui) library for building forms in React. The goal of this library is to solve 2 recurring issues that arise when building forms with other libraries:

  1. Performance Bottlenecks - With most other form libraries when you need to build forms with nested inputs i.e. not render directly within the parent Form element, you will run into performance issues.
  2. Sloppy Syntax/Code - Partly because of the first issue, with most other form libraries you almost always end up writing less than ideal code using shouldComponentUpdate or React.memo and the code becomes unreadable after a few months of development. Other reasons that may cause sloppy code is when you start needing dependent fields i.e. a field that depends on the value of another field or fields.

React Formz solves both of those problems enabling you to build forms that are performance optimized right out of the box. React Formz guarantess near constant performance when typing/interacting with inputs regardless of the number of inputs that are rendered. This ensures that your users never run into laggy forms and you never have to comprise on code quality. React Formz inputs only re-render when their value (or their dependencies if applicable) changes. This ensures maximum performance.

In addition, React Formz makes form building feel natural and declarative. Building forms are neccessarily a declarative coding paradigm where fields are identified often by the type of value they hold i.e. text, number, date, etc... React formz requires no boilerplate code to get started, in its most basic form you only need 2 components Form and Field.

import {
  Form,
  TextField,
  NumberField,
  DependentTextField,
} from "@zerry/react-formz";

const MyForm = () => {
  return (
    <Form initialValues={{ name: "", age: "", favoriteDrink: "" }}>
      <TextField
        required
        name="name"
        as={({ input }) => <input {...input} />}
      />
      <NumberField
        required
        name="age"
        as={({ input }) => <input {...input} />}
      />
      <DependentTextField
        name="favoriteDrink"
        dependencies={(formValues) => ({ age: formValues.age })}
        as={({ input }) => <input {...input} />}
        validate={(_, dependencies) => {
            if (dependencies.age < 21) return "You must be 21 to answer.";
            return null;
        }}
        onDependenciesChange={(dependencies, actions) => {
            if (dependencies.age < 21) {
                actions.setValue("None");
            }
        }}
      />
    </Form>
  );
};

Features

  • Written in Typescript
  • Accessibility built-in
  • First class support for dependent fields.
  • Custom form validation
  • Ability to render array/list data structures
  • Pre-built field validations for common use cases
  • Components only re-render if their values or dependent values change. No more use of React.memo or shouldComponentUpdate. Your formz will be maximally performant from the get go.
  • Near constant performance when using inputs and changing values. Because re-renders only occur when an inputs value changes, you can add as many components as needed and the performance will be the same. No more laggy typing on large forms.
  • Ability to persist form state locally and rehydrate when a user returns. Useful for when users partially complete a form and might accidentally exit the page.
  • Support for components or hooks, we don't care how you want to use react. All components have an equivalent hook that you can use for building your own primitives. So, the Field component has a useField hook.