Redux Form driver for k-ramel
yarn add @k-ramel/driver-redux-form regeneratorRuntime
You have to wrap your application with react-redux
Provider and giving the k-ramel store created via createStore
in order to work.
In store definition (See main documentation about description)
/* store.js */
import { createStore } from 'k-ramel'
import reduxform from '@k-ramel/driver-redux-form'
export default createStore(
{
/* your store description */
},
{
drivers: {
form: reduxform({ path: 'ui.form', getState: state => state.ui.form }) // default is { path: 'form' }
},
},
)
In a reaction (See main documentation about listeners/reactions)
/* reaction.js */
export const signin = (store, action, drivers) => {
const { form, http } = drivers
const signinForm = form('signin')
const loginValues = signinForm.getFormValues()
// check login is not empty
if (loginValues.login && loginValues.password) {
signinForm.setSubmitSucceeded()
} else {
signinForm.setSubmitFailed()
}
}