final-form

React-Final-Form: Set initialValues from props, form state resets on props change

怎甘沉沦 提交于 2021-02-20 11:24:48
问题 I have a component, that takes a balance prop, and this balance prop can change over time. I then have a React Final Form to send a transaction, with usual fields amount to send, receiver... And in my validate , I just check that the user has enough balance to send the transaction. However, if my balance changes when the user is inputting something, then the whole form resets. How would you only reset part of the form state? See this codesandbox for an example: https://codesandbox.io/s

Calling an async redux action creator on form submission

和自甴很熟 提交于 2021-02-11 06:36:26
问题 In a typical React/Redux app it's pretty common to use redux-thunk and async action creators to trigger an AJAX request and dispatch actions on start/success/failure of this request. However, I can't find a way to integrate such a function with react-final-form. Its redux submission example is using react-redux-promise-listener which dispatches an action immediately, but does not let me call my async action creator. It is possible to integrate react-final-form with a redux app that uses an

How do I combine `final-form-calculate` with `final-form-array`

强颜欢笑 提交于 2020-05-15 10:05:08
问题 I have a form which uses react-final-form-array in order to have many "Attendees". I'm wanting each of the Attendee.Email inputs to do a web lookup and then set the Attendee.FirstName and Attendee.Surname based off the result. I'm not sure how this should be expressed with a final-form-calculate decorator. Specifically, I don't know how to reference the individual form item within the array. Here's what I've got as a start: const MyForm = props => { const calculator = createDecorator( { field

How do I combine `final-form-calculate` with `final-form-array`

一个人想着一个人 提交于 2020-05-15 10:04:08
问题 I have a form which uses react-final-form-array in order to have many "Attendees". I'm wanting each of the Attendee.Email inputs to do a web lookup and then set the Attendee.FirstName and Attendee.Surname based off the result. I'm not sure how this should be expressed with a final-form-calculate decorator. Specifically, I don't know how to reference the individual form item within the array. Here's what I've got as a start: const MyForm = props => { const calculator = createDecorator( { field

Mutate state based on existing fields

≯℡__Kan透↙ 提交于 2019-12-11 07:33:21
问题 With React-Final-Form, I am creating a control that allows users to be listed ina directory if a radio button is clicked. In the click handler, I wish to auto-populate a textbox with the user's first and last names. I am doing this with a mutator, and I'm hoping I can get confirmation that I am doing this correctly, as I couldn't find documentation about the lastFieldState property I'm leveraging: setDisplayName: (args, state, utils) => { const { firstname, lastname } = state.fields; const

How to set/change Field value from external user action 🏁 React Final Form

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 16:30:18
问题 There are many situations in which we might want to set the value of a specific field within a form to help out the user. For example, an online fruit store may ask users how many apples they want to buy. To help users out, we could have 3 buttons such as "minimum" - sets field value to the minimum quantity the store can feasibly sell "maximum" - ditto, but for max "what I bought last time" - sets field value to the quantity of apples the user bought the last time After going over what I

How to set/change Field value from external user action

血红的双手。 提交于 2019-12-03 11:01:26
There are many situations in which we might want to set the value of a specific field within a form to help out the user. For example, an online fruit store may ask users how many apples they want to buy. To help users out, we could have 3 buttons such as "minimum" - sets field value to the minimum quantity the store can feasibly sell "maximum" - ditto, but for max "what I bought last time" - sets field value to the quantity of apples the user bought the last time After going over what I thought were the two most relevant examples ( Loading and Initializing Values and Calculated Fields ), I