Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-redux-form

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-redux-form

This is simplest redux form

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by300%
Maintainers
1
Weekly downloads
 
Created
Source

Simplest Redux Form

Higher order component for React Redux forms (inspired by redux-form)

Note

Idea of this library is 100% inspired from redux-form (v5).

This library is subset of redux-form for small / few forms. If your application is form heavey with large / complex form please use redux-form.

I have implemented this libray for following reasons :-

  • redux-form is great way of managing forms within application with react and redux.
  • For small forms using large library will add up unnecessary bundle size increase, this library focus on simple and small version of redux-from
  • Scope of this library will be very minimal, if you want full fledge library please use redux-form.

Installation

$ npm install --save simple-redux-form

Usage

Step #1

The first thing, you have to mount simple-redux-form reducer to your redux reducers. Configure this inside your rootReducers.

import {reducer as simpleFormReducer} from 'simple-redux-form';
const reducers = {
  // your other reducers
  form: simpleFormReducer  
}

Step #2

You need to decorate your component with simpleReduxForm.

import simpleReduxForm from 'simple-redux-form'
const fields = ['firstName', 'lastName'];
function validate(values) {
  const errors = {};
  if (!values.firstName) {
    errors.firstName = 'Required';
  }
  if (!values.lastName) {
    errors.lastName = 'Required';
  }
  return errors;
}

const MyNewForm = ({ fields: {firstName, lastName } }) => (
  <form>
    <input {...firstName} />
    <input {...lastName} />
  </form>
)

export default simpleReduxForm({
  fields: fields,
  validate: validate,
})(MyNewForm)

Each field in the fields prop contains the value a onChange, error , touched as sugger props to each field.

You can also pass fields as props.

For custom Input components this library expose , setValue function with each field for setting vlaues manually.

Todo

  • Docs
  • Examples
  • Test Cases

License

MIT

Keywords

FAQs

Package last updated on 25 Sep 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc