Bug: ...TypeError: destroy is not a function...from commitHookEffectListUnmount()
See original GitHub issueThis error pops up whenever I save to refresh (fast refresh)…it goes away when I make a different change only to re-appear in the next other change. appear-disappear-appear…
Unhandled Runtime Error
TypeError: destroy is not a function
Call Stack
commitHookEffectListUnmount
node_modules/react-dom/cjs/react-dom.development.js (19710:0)
commitPassiveHookEffects
/_next/static/chunks/main.js (40064:11)
HTMLUnknownElement.callCallback
node_modules/react-dom/cjs/react-dom.development.js (188:0)
Object.invokeGuardedCallbackDev
/_next/static/chunks/main.js (20533:16)
invokeGuardedCallback
node_modules/react-dom/cjs/react-dom.development.js (292:0)
flushPassiveEffectsImpl
/_next/static/chunks/main.js (43149:9)
unstable_runWithPriority
node_modules/scheduler/cjs/scheduler.development.js (653:0)
runWithPriority$1
/_next/static/chunks/main.js (31335:10)
flushPassiveEffects
node_modules/react-dom/cjs/react-dom.development.js (22820:0)
<unknown>
/_next/static/chunks/main.js (42995:11)
workLoop
node_modules/scheduler/cjs/scheduler.development.js (597:0)
flushWork
/_next/static/chunks/main.js (49188:16)
MessagePort.performWorkUntilDeadline
node_modules/scheduler/cjs/scheduler.development.js (164:0)
I’m running on…
"react": "^16.13.1",
"react-dom": "^16.13.1",
I believe it comes from here
function commitHookEffectListUnmount(tag, finishedWork) {
var updateQueue = finishedWork.updateQueue;
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
if (lastEffect !== null) {
var firstEffect = lastEffect.next;
var effect = firstEffect;
do {
if ((effect.tag & tag) === tag) {
// Unmount
var destroy = effect.destroy;
effect.destroy = undefined;
// THIS IS WHERE IT HAPPENS...WHY NOT
// CHECK IF IT'S AN ACTUAL FUNCTION ???
if (destroy !== undefined) {
destroy();
}
}
effect = effect.next;
} while (effect !== firstEffect);
}
}
Scoped
if (destroy !== undefined) {
destroy();
}
Even though it’s not undefined
, it might also not be a function…I assume that’s the case so why not check to see if its an actual function before calling it?
Issue Analytics
- State:
- Created 3 years ago
- Comments:16
Top Results From Across the Web
Fix the "Uncaught TypeError: destroy is not a function" Error in ...
This React error seems particularly cryptic, but ends up making a lot of sense when you get the hang of the useEffect hook....
Read more >React — Uncaught TypeError: destroy is not a function - Medium
While experimenting with useEffect hooks in React and React Native, I came across the following error: and my app was unable to run....
Read more >Getting error after I put Async function in useEffect
If you return anything from useEffect , it has to be a function. ... A Promise is not a function. so React stumbles...
Read more >typeerror: destroy is not a function at safelycalldestroy - You.com
This causes the error when the component is unmounting due to navigation. Solution. There's no reason for the callback to be async ,...
Read more >Getting error "destroy is not a function" in Plasmic Studio
Uncaught TypeError: destroy is not a function at safelyCallDestroy (react-dom.development.js?ac89:22932:1) at commitHookEffectListUnmount ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oops
if (status === "collected" || status === "cancelled") return true;
might be the devilThere you are returning something other than
undefined
or a function.To return early you can return nothing: