final-form / final-form/react-final-form

Default value on a field is not broadcasted to `value` subscribers

Open
#891 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?

Bug report.

### What is the current behavior?

Setting a default value on a field does not notify its listeners. Therefore, the value of the field cannot be used in other components (I want to do some calculations with it so I'd need the value).

The behaviour can be clearly seen in the included sandbox. If you set the `subscription` prop on the `Form` to `{}`, the `AmountSubscriber` component is not rerendered after rendering the `Input` component.

### What is the expected behavior?

When using `defaultValue` on a `Field`, subscribers on the `value` receive the default value.

### Sandbox Link

https://codesandbox.io/s/react-final-form-field-listener-questions-scenario-1-ij2zh

### What's your environment?

React 17 & RFF 6.5.2 (in the sandbox, I have the same issue with React 16.13.1)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.