-
Notifications
You must be signed in to change notification settings - Fork 4k
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(Sticky): prevent npe error after unmount of component #2854
Conversation
@@ -217,7 +220,7 @@ export default class Sticky extends Component { | |||
didReachContextBottom = () => { | |||
const { offset } = this.props | |||
|
|||
return (this.stickyRect.height + offset) >= this.contextRect.bottom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these lines changed because of prettier/eslint --fix
Codecov Report
@@ Coverage Diff @@
## master #2854 +/- ##
==========================================
+ Coverage 99.74% 99.74% +<.01%
==========================================
Files 160 160
Lines 2777 2779 +2
==========================================
+ Hits 2770 2772 +2
Misses 7 7
Continue to review full report at Codecov.
|
692ad5f
to
def4afe
Compare
bbd209b
to
6915f52
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made some style changes, LGTM 👍 @fracmak thanks for PR!
Released in |
This fixes a simple problem where the event listeners call handleUpdate() which calls requestAnimationFrame to call the update function in the next tick, but if the component unmounts between the handleUpdate call and the requestAnimationFrame firing, we get an NPE error because the handleTriggerRef function has been fired with null as the ref ( reference: https://reactjs.org/docs/refs-and-the-dom.html#adding-a-ref-to-a-dom-element ).
This prevents that from happening by saving the requestId from requestAnimationFrame and clearing it on componentWillUnmount