-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
Bug report
Current Behavior
Value of meta.initialValue is null in case if path is path.to.property for object
{
"path": {
"to": null
}
}const [_, meta] = useField("path.to.property")
meta.initialValue === nullExpected behavior
Value of meta.initialValue is undefined
const [_, meta] = useField("path.to.property")
meta.initialValue === undefinedSuggested solution(s)
export function getIn(
obj: any,
key: string | string[],
def?: any,
p: number = 0
) {
const path = toPath(key);
while (obj && p < path.length) {
obj = obj[path[p++]];
}
// check if path is not in the end
if(p !== path.length && obj === null)
return undefined
return obj === undefined ? def : obj;
}Your environment
| Software | Version(s) |
|---|---|
| Formik | 2.2.5 |
| React | 16.14.0 |
| Operating System | linux |
Reactions are currently unavailable