-
Notifications
You must be signed in to change notification settings - Fork 93
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
Prevent React setState on unmounted Component #12
base: master
Are you sure you want to change the base?
Conversation
Prevent React setState on unmounted Component
@@ -37,11 +39,13 @@ exports.InViewPort = class extends Component { | |||
return | |||
} | |||
this.myview.measure((x, y, width, height, pageX, pageY) => { |
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.
Check also here that component is mounted before starting timeout (failsafe).
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.
Technically it is already failsafe "startWatching" is called only in "componentDidMount" and "componentWillReceiveProps" these lifecycle methods are invoked after the component are mounted
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.
Being public methods they can be called from outside...
Although there is a method "stopWatching" which is called in "componentWillUnmount" and clear the interval, is possible that the native method "measure" async callback is returned with the component already unmounted.