redux-form

Redux-form 6.0.0 access error outside Field component

左心房为你撑大大i 提交于 2019-12-01 10:42:27
In Redux-form v5 I was able to access to the "inline" errors (async validation) from anywhere in the decorated form, like so: const fields = [ 'email' ] // inside the decorated form const { email } = this.props.fields console.log(email.error) // 'the validation error of the 'email' field How can I achieve the same thing using Redux-form 6.0.0+ ? If you are wanting to display the error next to the input, then it should be handled in the component that you pass to Field . If you want to display all the errors together, like at the bottom of the form by the submit button, you could use the new

My redux-form is reinitialized when switching language by changing react-intl wrapper props

主宰稳场 提交于 2019-12-01 09:52:31
I'm wrapping my app inside an IntlProvider from react-intl v2 , like this: <IntlProvider locale={this.props.lang} messages={this.props.messages}> And I have my react-form forms down the tree. Everything is great. But if I'm starting to fill up a form, and I decide to change the language of the UI (by listening to an action that will update my lang and messages props through my redux store), the form is being reset :-/ I see the action redux-form/INITIALIZE being fired when the lang changes. And it happens even if I pass destroyOnUnmount: false to reduxForm() . It did not happen with

Cancel componentWillUnmount if a form is incomplete

左心房为你撑大大i 提交于 2019-12-01 09:09:33
I have a form setup with redux-form and basically want to create a scenario where if there's content filled in any of the form's inputs and you try to navigate away from the page you get a prompt. The intent is to cancel the page unmount or page nav if they click Cancel . I tried creating a conditional, that if fulfilled would just return but it still navigates away from the current page. This is probably natural and that I'm not privy to the react/react-router workflow just yet but for the time being would anyone be able to explain the best approach for this? Is there something in general

Redux-form 6.0.0 access error outside Field component

社会主义新天地 提交于 2019-12-01 08:37:04
问题 In Redux-form v5 I was able to access to the "inline" errors (async validation) from anywhere in the decorated form, like so: const fields = [ 'email' ] // inside the decorated form const { email } = this.props.fields console.log(email.error) // 'the validation error of the 'email' field How can I achieve the same thing using Redux-form 6.0.0+ ? 回答1: If you are wanting to display the error next to the input, then it should be handled in the component that you pass to Field . If you want to

My redux-form is reinitialized when switching language by changing react-intl wrapper props

こ雲淡風輕ζ 提交于 2019-12-01 07:12:02
问题 I'm wrapping my app inside an IntlProvider from react-intl v2, like this: <IntlProvider locale={this.props.lang} messages={this.props.messages}> And I have my react-form forms down the tree. Everything is great. But if I'm starting to fill up a form, and I decide to change the language of the UI (by listening to an action that will update my lang and messages props through my redux store), the form is being reset :-/ I see the action redux-form/INITIALIZE being fired when the lang changes.

redux-form : How to display form values on another component

有些话、适合烂在心里 提交于 2019-12-01 04:44:47
I am using redux-form 6.0.0-rc.5 and I am trying to display the form values as they are entered by the user. However, I want these values to be displayed from another component, not the redux form itself. So, my simplified App architecture would be like that : <App /> -> (main component -container ?-) <List /> -> (connect to form values and pass them down) <Elem /> -> (display form value) <Form /> -> (enter form values) The component is a redux-form mounted to 'form' and is working. Form = reduxForm({ form: 'formName' })(Form) What would be a good way of getting the form values (from state

redux-form : How to display form values on another component

怎甘沉沦 提交于 2019-12-01 02:22:54
问题 I am using redux-form 6.0.0-rc.5 and I am trying to display the form values as they are entered by the user. However, I want these values to be displayed from another component, not the redux form itself. So, my simplified App architecture would be like that : <App /> -> (main component -container ?-) <List /> -> (connect to form values and pass them down) <Elem /> -> (display form value) <Form /> -> (enter form values) The component is a redux-form mounted to 'form' and is working. Form =

React Native + Redux Form - Use keyboard next button to go to next TextInput field

不羁岁月 提交于 2019-11-30 21:28:38
I'm using Redux Form (RF) in a React Native application. Everything works fine but I can not figure out how to get the refs from the Field input to go to the next input field with Redux Form. Without RF this solution would work just fine. Here is my code: class RenderInput extends Component { const { input, nextField, refs, meta: { touched, error, warning }, input: { onChange } } = this.props render() { return ( <Input returnKeyType = {'next'} onChangeText={onChange} onBlur={input.onBlur} onFocus={input.onFocus} onSubmitEditing = {(event) => { // refs is undefined refs[nextField].focus() }}/>

Validate dynamically generated form in react using redux-form and revalidate?

て烟熏妆下的殇ゞ 提交于 2019-11-30 20:37:58
I'm using "revalidate" to validate "redux-form" forms, but I'm facing this situation where there's a form that is generated dynamically based on an API response that I map over it and display the inputs inside the form. Here's an example of how I normally validate "redux forms" with "revalidate ... const validate = combineValidators({ name: composeValidators( isRequired({ message: "Please enter your full name." }), hasLengthLessThan(255)({ message: "Name can't exceed 255 characters." }) )(), email: composeValidators( isRequired({ message: "Please enter your e-mail address." }), matchesPattern

How to dynamically build a redux form?

只愿长相守 提交于 2019-11-30 15:45:11
I'm looking to learn how to dynamically build a redux-form. Idea being, the component called, componentDidMount goes at fetches a list of items from the server and inserts them in the store, store.my_items: {'item1', 'itemB', 'itemZZZ', etc...} Now that these items are in the store, I want to build the redux-form with a Field for each item in store.my_items. Example, several of these dynamically created: <div> <label>ItemXXX</label> <div> <label> <Field name="ItemXXX" component="input" type="radio" value="1" /> {' '} 1 </label> <label> <Field name="ItemXXX" component="input" type="radio" value