New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

use-redux-form

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-redux-form

React hook for using Redux store

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-81.25%
Maintainers
1
Weekly downloads
 
Created
Source

use-redux-form

npm

With use-redux-form, any kind of form components can be possible to use simply with Redux store object.

Inspired by ReduxForm

Install

npm install use-redux-form

API

more docs are coming...

Usage

examples are coming...

import React from 'react'
import { useDispatch } from 'react-redux'
import useReduxForm from 'use-redux-form/es'

const Component = ({ isLoading }) => {
  const dispatch = useDispatch();

  const { handleSubmit, getFieldProps } = useReduxForm({
    storePath: 'user.form',

    disable: () => isLoading,

    validate: (values) => {
      const errors = {};

      if (!values.a) {
        errors.a = 'error!';
      }

      return errors;
    },

    onSubmit: ({ isInvalid, errors }) => {
      if (isInvalid) {
        return Object.values(errors).forEach((value) => {
          if (value) {
            someAlert(value);
          }
        });
      }

      dispatch(someAction());
    },

    // transform data before into props data
    // e.g. some components ask specific field type as value
    transform: ({ name, value }) => {
      if (name === 'a' && isData(value)) {
        return new Date(value);
      }

      return value;
    },

    onChange: ({ name, value }) {
      // name is key name
      // value is from field
      dispatch(someAction({ name, value }))
    },
  });

  return (
    <Field {...getFieldProps('some-field-name' />
    <Button onClick={handleSubmit}>Confirm</Button>
  )
}

Troubleshoot

Duplicate dependencies issues

You could have Invalid Hook Call Warning issue if you use such as npm link or something.

There is a way to solve this issue by using alias, please read this.

alias: {
  react: Path.resolve('./node_modules/react'),
  'react-redux': Path.resolve('./node_modules/react-redux'),
  ...
},

Todo

  • Unit test
  • Provide API doc
  • Provide examples
  • Provide actions, types

License

MIT

Keywords

FAQs

Package last updated on 28 Feb 2021

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