TypeError: connector.off is not a function
I get this error whenever I want to disconnect a user. Any idea how to fix that ?
Unhandled Runtime Error
TypeError: connector.off is not a function
Call Stack
eval
node_modules/@usedapp/core/node_modules/@web3-react/core/dist/core.esm.js (496:0)
HTMLUnknownElement.callCallback
node_modules/react-dom/cjs/react-dom.development.js (3945:0)
Object.invokeGuardedCallbackDev
node_modules/react-dom/cjs/react-dom.development.js (3994:0)
invokeGuardedCallback
node_modules/react-dom/cjs/react-dom.development.js (4056:0)
flushPassiveEffectsImpl
node_modules/react-dom/cjs/react-dom.development.js (23543:0)
unstable_runWithPriority
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (468:0)
runWithPriority$1
node_modules/react-dom/cjs/react-dom.development.js (11276:0)
flushPassiveEffects
node_modules/react-dom/cjs/react-dom.development.js (23447:0)
eval
node_modules/react-dom/cjs/react-dom.development.js (23324:0)
workLoop
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (417:0)
flushWork
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (390:0)
MessagePort.performWorkUntilDeadline
node_modules/react-dom/node_modules/scheduler/cjs/scheduler.development.js (157:0)
Could you provide some reproduction of that error?
@nezouse Ran into this as well. The issue comes from the EventEmitter implemented by AbstractConnector not always being a real EventEmitter. It will have some properties of the Node EventEmitter class but not all of them, including the off method.
I blindly tried installing the most recent events package and that solved the issue. I wonder if this has to do with webpack5 not polyfilling events and other node packages.
It doesn't look like @web3-react/core explicitly pins events as a dependency, so I'm willing to bet that's what it is.
@nezouse Ran into this as well. The issue comes from the
EventEmitterimplemented byAbstractConnectornot always being a realEventEmitter. It will have some properties of the NodeEventEmitterclass but not all of them, including theoffmethod.I blindly tried installing the most recent
eventspackage and that solved the issue. I wonder if this has to do with webpack5 not polyfillingeventsand other node packages.It doesn't look like
@web3-react/coreexplicitly pinseventsas a dependency, so I'm willing to bet that's what it is.
I've tried this and it doesn't seem to do anything other than change the error to:
TypeError: _.off is not a function
I tried reproducing this on recent version of useDApp, no luck. The error might have been fixed along the way? Here is an example of web3modal usage in useDApp, where I can connect and disconnect a user without any error.
https://example.usedapp.io/web3modal