-
Notifications
You must be signed in to change notification settings - Fork 66
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
If bound methods or fields are re-assigned, they become shared between instances #76
Comments
Committed failing test cases and fix for |
Does it happen if you use |
Yes, latest version before exporting of boundMethod and boundClass separately had this issue Before this commit new function will just override bound function, but it won't be re-bound later on. Above comit tried to overcome this by deleting original descriptor and letting binding to happen again, but this time binding will be done on function that might be instance-specific, because we are working with instance, not prototype in this case. In my case I was taking already bound function and debounced it |
@betalb Thanks for reporting this. PR welcome :) |
Created PR, but would like to revise it further, don't like appoach for |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I'd like to add, that there is also a possibility of memory leak. Minimal code to illustrate: class Base extends React.Component {
@boundMethod
method() {}
}
class Child extends Base {
method = debounce(super.method, 100);
}
Reproduction: https://codesandbox.io/s/autobind-debounce-memory-leak-jezks?file=/src/Child.js What it looks like in DevTools: So, can you fix the bug and the memory leak in two years? |
If bound methods or fields are re-assigned, they become shared between instances
Found this issue while trying to debounce bound method
Below test will fail
The text was updated successfully, but these errors were encountered: