-
Notifications
You must be signed in to change notification settings - Fork 220
[react-form] Use of useChoiceField results in Cannot read property 'dirty' of undefined #1261
Comments
@patsissons @TheMallen @michaelmelanson Any chance we can get this looked at? |
Actually, it appears that the following works: showNotification: useField(useChoiceField(product.showNotificationBanner)), If this is the correct way to utilize |
Thanks for the bug report! I think it was my change in #1296 that caused this, so I'll look into it for you. Sorry for the trouble. In the meantime I suggest going back to version 0.3.34 of |
Thanks @michaelmelanson! Also, I might have jumped the gun. When using showNotification: useField(useChoiceField(product.showNotificationBanner)), I am seeing the following for checkbox item values (instead of |
@michaelmelanson Any news on this? Having this fixed would make react-form more usable. |
Sorry for the delay here. I meant to get to this sooner, but with everything else going on I haven’t yet. It’s still on my radar, so I’ll get to it as soon as I can. |
I found a workable solution. For const showNotifications = useField(props.product.showNotifications);
// ...
<Checkbox label="Show notifications" {...asChoiceField(showNotifications)} /> This works great. However, const showNotifications = useChoiceField(props.product.showNotifications);
// ...
<Checkbox label="Show notifications" {...showNotifications} /> This results in For const notificationOptions = useField(props.product.notificationOptions);
// ...
<ChoiceList
choices={[
{
label: 'Always',
value: 'ALWAYS'
},
{
label: 'Never',
value: 'NEVER'
}
]}
selected={notificationOptions.value}
onChange={([value]) => notificationOptions.onChange(value)}
/> |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
@chaddjohnson that exactly solved my issue! Thanks a ton. |
Please note I do not have the ability to assign the "bug" label to this issue.
Overview
When using
useChoiceField
, I get an error,Cannot read property 'dirty' of undefined
. Here is a code snippet:I also tried
The error definitely occurs when using
useChoiceField
.Here is my checkbox (the error occurs whether or not this checkbox is in place):
Consuming repo
Building my own app using Shopify Polaris.
The text was updated successfully, but these errors were encountered: