0.0.3 • Published 5 years ago

drfrf v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

drfrf

CircleCI npm

Django REST framework - redux-form connector

Installation

$ yarn add drfrf

Usage

Compose the drfrf higher-order component with reduxForm:

import drfrf from "drfrf"
import { connect } from "react-redux"
import { compose } from "recompose"

const App = props => <form>...</form>

export default compose(
  drfrf({
    endpoint: "http://example.com/api/items/validate/",
  }),
  reduxForm({ ... })
)(App)

To-daa! Your form automatically queries the specified endpoint with every onChange and displays errors from the backend! 🎉

Browse the complete example here: https://github.com/Theodo-UK/drfrf/tree/master/example/frontend/src

API

drfrf exposes a single HOC which sets the asyncValidate prop for redux-form to use. This HOC accepts a configuration object with the following properties:

namedefaultdescription
endpointnoneURL to call with every change
method"POST"HTTP method to use

Backend integration

If you're using Django in your backend, check out drfrf for the backend.