0.0.1-beta.0 • Published 4 years ago

redux-input v0.0.1-beta.0

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

redux-input

Connect input components to redux by passing an action and a selector.

NPM JavaScript Style Guide

Install

npm install --save redux-input

Basic Usage

import React from 'react'
import { ReduxInput } from 'redux-input'
import { DatePicker } from 'antd'

import selectors from './selectors'
import actions from './actions'

const BasicExample = () => {
  return (
    <ReduxInput
      Component={DatePicker}
      selector={selectors.basicExampleInput}
      action={actions.basicExampleAction}
    />
  )
}
// selectors.js
const basicExampleInput = (state) => state.basic.example.input

// actions.js
const basicExampleAction = (payload) => ({
  type: 'BASIC_EXAMPLE/CHANGE',
  payload,
})

// reducer.js
import { createReducer } from '@reduxjs/toolkit'

combineReducers({
  input: createReducer(null, {
    'BASIC_EXAMPLE/CHANGE': (_, { payload }) => payload
  })
})

Documentation

Further examples are documented here

License

MIT © danielrob