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

Recalculation of height on resize event may cause null error #138

Open
cowardcalf opened this issue Mar 27, 2018 · 0 comments
Open

Recalculation of height on resize event may cause null error #138

cowardcalf opened this issue Mar 27, 2018 · 0 comments

Comments

@cowardcalf
Copy link

It could happen when the component unmounting, a resize event triggered but the event listener of resize hasn't been removed.

In my case, it's like the code below:

<ReactMedia query="(max-width: 768px)" render={() => (
  <Headroom>{/* some components */}<Headroom>
)} />

When resizing the window by dragging, from width small than 768px to a larger one, it may throw the error:

_this.setHeightOffset = function () {
_this.setState({
height: _this.inner.offsetHeight
});
_this.resizeTicking = false;
};

It's easy to reproduce in developer tools of Chrome.
Also, it happens in Edge, IE as well.

I have to set calcHeightOnResize={false} to avoid this error.
BTW, although since v2.2.0 the option of calcHeightOnResize has been added, there is no document mention that.

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

1 participant