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

Bug on Dropdown.componentWillUnmount() #2120

Closed
MeXaaR opened this issue Sep 25, 2017 · 9 comments
Closed

Bug on Dropdown.componentWillUnmount() #2120

MeXaaR opened this issue Sep 25, 2017 · 9 comments

Comments

@MeXaaR
Copy link

MeXaaR commented Sep 25, 2017

Simple bug on every component dependants on Dropdown (FormSelect, Select, etc...)
it happens since the last update

Error: Cannot read property '_bound' of undefined
TypeError: Cannot read property '_bound' of undefined
    at EventStack._unlisten (modules.js:47055)
    at EventStack.unsub (modules.js:47083)
    at Dropdown.componentWillUnmount (modules.js:48677)
    at modules.js:20397
    at measureLifeCyclePerf (modules.js:20064)
    at ReactCompositeComponentWrapper.unmountComponent (modules.js:20396)
    at Object.unmountComponent (modules.js:13040)
    at ReactCompositeComponentWrapper.unmountComponent (modules.js:20406)
    at Object.unmountComponent (modules.js:13040)

anybody has the same issue ?

@levithomason
Copy link
Member

I have not, but this may be related to #2117. It is being released now as 0.74.2. Let's see if it fixes it.

@levithomason
Copy link
Member

@MeXaaR please try the latest release, 0.74.2, and let us know if you're still seeing this bug.

@MeXaaR
Copy link
Author

MeXaaR commented Sep 25, 2017

Thanks guys, it work fine now

Great fix

@MeXaaR MeXaaR closed this as completed Sep 25, 2017
@ewiechowicz
Copy link

@levithomason I'm still seeing this on 0.74.2 and 0.75.1. Please see the trace below:

Error: Cannot read property '_bound' of undefined
TypeError: Cannot read property '_bound' of undefined
    at EventTarget._unlisten (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:91254:18)
    at EventTarget.unsub (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:91282:11)
    at EventStack.unsub (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:91125:19)
    at Dropdown.componentWillUnmount (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:99245:23)
    at http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:39978:25
    at measureLifeCyclePerf (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:39645:12)
    at ReactCompositeComponentWrapper.unmountComponent (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:39977:11)
    at Object.unmountComponent (http://localhost:3000/packages/modules.js?hash=0051c69b4aad0f180713cf5acfcf13ef81b7be36:32715:22)
    at Object.obj.(anonymous function) [as unmountComponent] (chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/backend.js:8598:20)

As a workaround I disabled componentWillMount:

import {
  Dropdown as BaseDropdown,
} from 'semantic-ui-react';

class Dropdown extends BaseDropdown {
  componentWillUnmount() {
    // don't call the buggy code
    // See datails at https://github.com/Semantic-Org/Semantic-UI-React/issues/2120
  }
}

@layershifter
Copy link
Member

Please fill our issue template, we need the reproduction case and its example on the codesandbox. We will reopen the issue once we will have it.

@mhagmajer
Copy link

+1

@layershifter can you work out the issue from the stack trace she provided? Seems like undefined reference kind of thing...

@layershifter
Copy link
Member

@mhagmajer Make codepen on sandbox and describe how we can reproduce it.

@mhagmajer
Copy link

mhagmajer commented Oct 24, 2017

@layershifter Despite my best effort, I wasn't able to isolate a clean example of this issue. However, I was able to pin down the bug in code:

this.target.removeEventListener(name, handler)

The line above causes error if handler is undefined (probably introduced in #1733). I propose to check if handler is defined before attempting to remove it.

@levithomason
Copy link
Member

What browser is this happening in? I'm unable to reproduce the issue. We also have passing tests that remove handlers multiple times. This covers removing undefined handlers.

can you work out the issue from the stack trace she provided? Seems like undefined reference kind of thing...

Not in this case, the error occurs in removeEventListener which is a browser function, not our code. The thing is, this browser method also handles undefined handlers without throwing:

image

Without a reproduction case, we cannot tell why this is happening. The proposed PR will only prevent the above workflows, removing an undefined handler. However, as I've shown, this is not the problem.

Please submit a reproduction and we can help.

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

No branches or pull requests

5 participants