react-hook-form / devtools

đź“‹ DevTools to help debug forms.
https://react-hook-form.com/dev-tools
MIT License
638 stars 48 forks source link

Cannot read properties of undefined (reading 'watch') #184

Closed adamsuskin closed 8 months ago

adamsuskin commented 1 year ago

I haven't been able to successfully run the devtools in my repo. I have put the DevTools component underneath a FormProvider. I get the following error:

Uncaught TypeError: Cannot read properties of undefined (reading 'watch')
    at useWatch (useWatch.ts:194:1)
    at useExportControlToExtension (useExportControlToExtension.ts:15:1)
    at DevTool (devTool.tsx:38:1)
    at renderWithHooks (react-dom.development.js:14985:1)
    at mountIndeterminateComponent (react-dom.development.js:17811:1)
    at beginWork (react-dom.development.js:19049:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at beginWork$1 (react-dom.development.js:23964:1)
useWatch @ useWatch.ts:194
useExportControlToExtension @ useExportControlToExtension.ts:15
DevTool @ devTool.tsx:38
renderWithHooks @ react-dom.development.js:14985
mountIndeterminateComponent @ react-dom.development.js:17811
beginWork @ react-dom.development.js:19049
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
beginWork$1 @ react-dom.development.js:23964
performUnitOfWork @ react-dom.development.js:22776
workLoopSync @ react-dom.development.js:22707
renderRootSync @ react-dom.development.js:22670
performSyncWorkOnRoot @ react-dom.development.js:22293
(anonymous) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:646
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
discreteUpdates$1 @ react-dom.development.js:22420
discreteUpdates @ react-dom.development.js:3756
dispatchDiscreteEvent @ react-dom.development.js:5889

Versions are: @hookform/devtools: 4.3.0 react-hook-form: 6.15.8

iprime2 commented 8 months ago

Are you still facing this issue @adamsuskin

adamsuskin commented 8 months ago

Are you still facing this issue @adamsuskin

No, and IIRC this was resolved with an originating issue of compatibility between the 4.3.x version of devtools with the RHF 6.x. Pretty sure solution was to downgrade devtools (or upgrade RHF to 7.x but that was off the table given size of migration at the time).