final-form / react-final-form

🏁 High performance subscription-based form state management for React
https://final-form.org/react
MIT License
7.38k stars 480 forks source link

Parse function should have access to the last value #192

Open renato-bohler opened 6 years ago

renato-bohler commented 6 years ago

Are you submitting a bug report or a feature request?

Feature request.

What is the current behavior?

The API for the parse function doesn't provide the value before the change.

parse?: ((value: any, name: string) => any) | null

What is the expected behavior?

I think we should have access to the value before the change at the parse function, or we should have another function on the value lifecycle. This would make possible stuff like creating an redux-form-input-masks adaptor to use with react-final-form.

I'm currently experimenting some stuff on this sandbox.

What's your environment?

react-final-form@3.1.4 final-form@4.3.1 redux-form-input-masks@1.0.1

MichaelBuen commented 6 years ago

For the meantime, you can access old value from values and name, example:

https://codesandbox.io/s/6zl0nx0wx3

taschetto commented 5 years ago

This feature would be much appreciated. Using redux-form-input-masks with redux-form is amazing and works just right. It would be terrific to be able to use it along final-form. The absense of this port is keeping me from migrating my apps to final-form.

taschetto commented 4 years ago

@renato-bohler how did you work around this? Are you still using redux-form?

renato-bohler commented 4 years ago

Unfortunately, I haven't. I'm not using react-final-form or redux-form in any of the projects I'm currently working on, but would still love to port redux-form-input-masks to react-final-form if this was addressed at some time.