Demo integrating form components with ReduxForm
See original GitHub issueIt would be super helpful to have a few canonical examples of how to integrate the form components with ReduxForm.
Additionally, it may be worth considering adding some ReduxForm HOC to wrap the components:
// Wrapped component
export function ReduxFormTextInput(props) {
const {
input: {onChange, value},
placeholder,
disabled,
...otherProps
} = props;
return (
<TextInput
onChange={onChange}
value={value}
placeholder={placeholder}
disabled={disabled}
{...otherProps}
/>
);
}
// Example use:
<Field
component={ReduxFormTextInput}
placeholder="placeholder"
name="fieldName"
/>
If BaseUI doesn’t expose these wrappers, I think that each project that wants to integrate with ReduxForm will need to reimplement this boilerplate.
I wanted to kick off a discussion of where these examples/wrappers belong. Maybe it makes more sense to create a separate baseui-reduxform
repo to prevent bleeding concerns?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Demo integrating form components with ReduxForm #150
Demo integrating form components with ReduxForm #150 ... This wrapper accepts all redux-form Field props and any props that the ...
Read more >Redux Form - Getting Started
To connect your React form components to your Redux store you'll need the following pieces from the redux-form package: Redux Reducer: formReducer ,;...
Read more >How to Integrate Redux Form in React Native Application
In this step-by-step guide for beginners, with the help of the redux form example, we will learn how to integrate the redux form...
Read more >react-semantic-redux-form
Integration of Semantic UI React with Redux Form. Available Components. Components with Field suffix are Form.Field(A field is a form element ...
Read more >Integrate Redux Form in your React App - Part 1
This is a simple demonstration of how to connect all the standard HTML form elements to redux-form. create src/SimpleForm.js as follow:.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is an example of BaseUI’s stateful input wrapper that we use with redux-forms. This wrapper accepts all redux-form Field props and any props that the
StatefulInput
is expecting.This is how we would utilize the above
ReduxFormTextInput
component in a redux-formField
:You can see that we pass any of the BaseUI props (overrides, placeholder, etc.) directly into the
Field
. The wrapper layer utilizesmeta
for error handling, and directly utilizes redux-formvalue
andonChange
.If you want your field to populate with data, all you need to do is:
initialValues
prop into your form component… Each key should correlate to the name of your field. (Ex:initialValues: { callbackName: 'Casey' }
).value
from the wrapper component to that prop.@Warbring3r’s solution was super helpful, but we ran into issues around redux-form’s default value being an empty string: https://redux-form.com/8.2.0/docs/api/field.md/#-code-input-value-any-code-
This ended up being incompatible with the Base Select component, and we would not see the placeholder (#1252). We also removed the inline function declaration to avoid memory leaks. For those who might find this helpful, our HOC ended up looking like this:
And our usage looks like: