Initialization of status
See original GitHub issueBug, Feature, or Question?
Bug
Current Behavior
When including a reference to this.status.property in a Formik inner component, where property is determined after handleSubmit is called, initially referencing this.status.property results in error: Cannot find property ‘property’ of undefined
Desired Behavior
Reference to this.status.property should return undefined on component initialization.
Suggested Solutions
After a few hours of digging, and looking at this CodeSandbox, the current solution is to append this.status && before this.status.property so the conjunction short-circuits to false.
Given this is a basic JS fact of how objects evaluate, it may seem like the solution is obvious, but I found the documentation regarding how status is handled a little sparse.
Maybe there could be a initializeStatus property for the Formik component which allows you to specify status on page initialization?
- Formik Version: 0.11.11
- React Version: 16.0
- TypeScript Version: N/A
- CodeSandbox Link: https://codesandbox.io/s/ppnkqv78wq
- OS: Windows 10
- Node Version: 9.5
- Package Manager and Version: npm 5.6.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:14 (4 by maintainers)

Top Related StackOverflow Question
I would recommend providing a default parameter for status in a destructuring. As follows:
Although status could be an empty object by default, what do you think @jaredpalmer?
Added in 1.5.0