Open quicksnap opened 5 years ago
Ran into this today with the <Field />
component. The type
prop is turning into an undefined
value. This is an issue for us since we have been using that type
prop to pass down the input type to the <input/>
inside of the <Field />
.
The current workaround is reverting back to v4.1.0. We checked all the versions and that was the last working version with the type
prop. Or, of course, changing the name of the prop to something other than type
Oh hey @erikras! Long time no chat. =P
Finally am getting to use this!
Are you submitting a bug report or a feature request?
Bug!
What is the current behavior?
useField()
returnsinput: { ...stuff, type: undefined }
What is the expected behavior?
Instead, the key should not be deifined
Sandbox Link
https://codesandbox.io/s/react-final-form-simple-example-p35vk
What's your environment?
react-final-form@6.3.0
Other information
The reason this is problematic is that, when spreading into something, it will override
type: 'something'
withtype: undefined
since the key's value is actually set toundefined
. This is due to a bad optimization in the compiled output:In the uncompiled code, there is a check for
undefined
before assigning to the key. In compiled code, that check is not there, and it explicitly setstype
to_ref.type
, which is undefined by default.I haven't looked at this build on why this is.