Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

formux

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

formux

Makes constructing forms in a React/Redux application easier

latest
Source
npmnpm
Version
2.1.2
Version published
Maintainers
1
Created
Source

formux

Makes constructing forms in a React/Redux application easier.

Usage

Install:

$ npm install --save formux

Define your components:

import { Form, reduxField } from 'formux';
import * as Validator form 'extensible-validator';

// define a reusable input component
// this one automatically adds the 'has-error' class if there is a validation error
const Input = reduxField()(
  (props) => <input type='text' value={props.value} onChange={props.onChange} className={props.valid ? '' : 'has-error'} />
);

// make a form
// wire up onValidSubmit which only gets called if the form is valid
const Page = (
  <div>
    ...
    <Form path='person' onValidSubmit={addPerson}>
      <Input name='name' validator={new Validator.String().required()} />
      <Input name='age' validator={new Validator.Number().required()} />
      <button type='submit'>Submit</button>
    </Form>
  </div>
);

You also need to install the reducer, e.g.:

import { reducer } from 'formux';
import { combineReducers } from 'redux';

const rootReducer = combineReducers({
  ...
  forms: reducer
});

Keywords

redux

FAQs

Package last updated on 15 Aug 2017

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