Submission errors with combination of subscription prop disable returned submission error
Are you submitting a bug report or a feature request?
Submitting a bug report
What is the current behavior?
simple form with both feature, Submission errors and
subscription={{ submitting: true, pristine: true }} disable the returned submission error
https://codesandbox.io/s/intelligent-pine-kotjt?file=/index.js
What is the expected behavior?
both feature should work together unless I missed something in the docs...
Sandbox Link
What's your environment?
"final-form": "4.18.7",
"react-dom": "16.13.0",
"react": "16.13.0",
"react-final-form": "6.3.5",
Other information
Investigation Results
I've investigated this issue and confirmed the behavior you're experiencing.
Root Cause: This is actually expected behavior for the subscription system in React Final Form.
Explanation:
When you provide a custom subscription prop to <Form>, you're explicitly specifying which form state fields you want to subscribe to. The component will only re-render when those specific fields change, and only those fields will have values in the render props.
In your case:
subscription={{ submitting: true, pristine: true }}
This means only submitting and pristine are subscribed to. Any other form state fields (including submitErrors) will be undefined.
Solution:
Add submitErrors: true to your subscription:
<Form
onSubmit={onSubmit}
subscription={{ submitting: true, pristine: true, submitErrors: true }}
>
{({ handleSubmit, submitErrors }) => (
// Your form JSX
)}
</Form>
Why it works this way:
The subscription system is designed for performance optimization. By default, the Form component subscribes to ALL form state (subscription={all}), which means it re-renders whenever any form state changes. When you provide a custom subscription, you're opting into fine-grained control to avoid unnecessary re-renders.
Recommendation: This issue should be closed as "working as intended." However, this might be worth documenting more clearly in the README to help users understand the subscription system.
Let me know if you have questions or if you'd like me to prepare a PR to improve the documentation around this!