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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-redux-formal

v0.5.0

Published

Form state management and building library for react and redux

Downloads

76

Readme

react-redux-formal

Long name, I know. But the name is supposed to convey that it's build on top of both react and redux.

Formal came into life after I experimented with redux-form but found it a bit too "heavy" for most usecases I required. It came with slightly too much out of the box so I decided to make a more lightweight alternative.

Installation

As you'd expect, react-redux-formal is available on npm.

$ npm install --save react-redux-formal

As the name would suggest, react-redux-formal depends on redux as well as react-redux, so you might need to issue

$ npm install --save redux react-redux

Setup

After you've installed the package, you'll need to add the formReducer to your store and expose the store to your app through react-redux's Provider.

Note: react-redux-formal requires the formReducer to be mounted at state.form.

import { Provider } from 'react-redux';
import { formReducer } from 'react-redux-formal';
import { render } from 'react-dom';
import { combineReducers, createStore } from 'redux';

const store = createStore(combineReducers({
  form: formReducer,
}));

render((
  <Provider store={store}>
    <App />
  </Provider>
), document.getElementById('app-container')):

Usage

With the reducer in place you can use the connectForm function to hook your app up and have fields injected. For example, a simple login form component might look something like this:

import PropTypes from 'prop-types';
import React from 'react';
import { connectForm, validators } from 'react-redux-formal';

export class Signup extends React.Component {
	static propTypes = {
		fields: PropTypes.object.isRequired,
		formValidate: PropTypes.func.isRequired,
		getValues: PropTypes.func.isRequired,
	}

	constructor() {
		super();

		this.onSubmit = this.onSubmit.bind(this);
	}

	onSubmit(ev) {
		ev.preventDefault();

		this.props.formValidate()
			.then(values => {
				/* do stuff with values */
			})
			.catch(() => {});
	}

	render() {
		const { fields } = this.props;

		return (
			<form onSubmit={this.onSubmit}>
				<fields.username />
				<fields.email />
				<fields.password />

				<button type="submit">Sign up</button>
			</form>
		);
	}
}

export default connectForm(() => {
	name: 'signup',
	fields: {
		username: {
			type: 'text',
			label: 'Username',
			validators: [
				validators.required('Username is required'),
			],
		},
		email: {
			type: 'text',
			label: 'E-mail',
			validators: [
				validators.required('E-mail is required'),
			],
		},
		password: {
			type: 'text',
			label: 'Password',
			validators: [
				validators.required('Password is required'),
			],
		},
	},
})(Signup);

API

connectForm(mapStateToOptions)(component)

Generate fields that are injected into the wrapped component. Does not modify the component passed to it. Instead it returns a new component which wraps the original component which should be used instead.

  • mapStateToOptions (Function): A function which should return an object with options for your form. This gets passed the same arguments as redux connect's mapStateToProps. The return options object can have the following keys:
    • name (String): Name of the form, this is used to store the form in redux under its own namespace. Ensure this is unique for each form.
    • fields (Object): Object containing field specifications. The key will be reused when injecting fields into your component.
    • [values] (Object): Initial values to populate the fields with.
    • [inputTypes] (Object): Custom input types. This can be used to specify your own input types if you don't want to use the ones provided.
  • component (Component): The component to wrap.

License

MIT © Chiel Kunkels