react-final-form-listeners icon indicating copy to clipboard operation
react-final-form-listeners copied to clipboard

<OnChange> without name attribute broken after react-final-form update

Open ArturBaybulatov opened this issue 4 years ago • 1 comments

Are you submitting a bug report or a feature request?

Bug report (minor update of a peer dependency, react-final-form (6.4.0 -> 6.5.0), causes breaking change).

What is the current behavior?

When using an <OnChange> component without name attribute specified, it used to pass a whole values object to the children callback as an argument. But with a recent update of react-final-form from 6.4.0 to 6.5.0, the error started appearing:

prop name cannot be undefined in <Field> component

What is the expected behavior?

The callback passed a whole object of values if no field name specified to listen to in <OnChange> component. See the screenshot with desired behavior below.

image

Sandbox Link

Sandbox with desired behavior (notice an outdated react-final-form version, 6.4.0). Try typing in fields and see the console output. https://codesandbox.io/s/affectionate-raman-r7qm4?file=/src/App.js&expanddevtools=1

Try changing the version to the latest, and error starts appearing.

ArturBaybulatov avatar Jul 21 '20 21:07 ArturBaybulatov

Are you submitting a bug report or a feature request?

Bug report (minor update of a peer dependency, react-final-form (6.4.0 -> 6.5.0), causes breaking change).

What is the current behavior?

When using an <OnChange> component without name attribute specified, it used to pass a whole values object to the children callback as an argument. But with a recent update of react-final-form from 6.4.0 to 6.5.0, the error started appearing:

prop name cannot be undefined in <Field> component

What is the expected behavior?

The callback passed a whole object of values if no field name specified to listen to in <OnChange> component. See the screenshot with desired behavior below.

image

Sandbox Link

Sandbox with desired behavior (notice an outdated react-final-form version, 6.4.0). Try typing in fields and see the console output. https://codesandbox.io/s/affectionate-raman-r7qm4?file=/src/App.js&expanddevtools=1

Try changing the version to the latest, and error starts appearing.

You can use FormSpy from RFF instead of onChange from this library to subscribe to changes of any Field value in Form. Seems like onChange component was created only for subscription to one Field and to listen to only changes from this Field.

mihanizm56 avatar Jul 23 '20 09:07 mihanizm56