Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined errors for focusing unmounted elements #404

Merged
merged 2 commits into from
Dec 15, 2020
Merged

Fix undefined errors for focusing unmounted elements #404

merged 2 commits into from
Dec 15, 2020

Conversation

milesj
Copy link
Contributor

@milesj milesj commented Dec 12, 2020

@vadimdemedes

Ran into an issue where focusNext was called in a side-effect, but the focusables (children) were unmounted before it fired, resulting in this error. Just adding some undefined checks

error The above error occurred in the <InternalApp> component:
    in InternalApp

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.
/Users/milesj/Projects/packemon/node_modules/yoga-layout-prebuilt/yoga-layout/build/Release/nbind.js:53
        throw ex;
        ^

TypeError: Cannot read property 'id' of undefined
    at App.<anonymous> (/Users/milesj/Projects/packemon/node_modules/ink/build/components/App.js:119:70)
    at getStateFromUpdate (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:3420:35)
    at processUpdateQueue (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:3494:21)
    at updateClassInstance (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:4297:5)
    at updateClassComponent (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:8196:20)
    at beginWork$1 (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:9962:16)
    at Object.invokeGuardedCallbackImpl (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:11563:10)
    at invokeGuardedCallback (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:11740:31)
    at beginWork$$1 (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:15778:7)
    at performUnitOfWork (/Users/milesj/Projects/packemon/node_modules/react-reconciler/cjs/react-reconciler.development.js:14696:12)

@sindresorhus sindresorhus changed the title Fix undefined errors for focusing unmounted elements. Fix undefined errors for focusing unmounted elements Dec 12, 2020
@vadimdemedes
Copy link
Owner

Good catch, thanks!

@vadimdemedes vadimdemedes merged commit deb9d96 into vadimdemedes:master Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants