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

check if the content and the wrapper exists before computing the sizes #123

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
"url": "https://github.com/souhe/reactScrollbar/issues"
},
"homepage": "https://github.com/souhe/reactScrollbar"
}
}
8 changes: 4 additions & 4 deletions src/js/ScrollArea.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ export default class ScrollArea extends React.Component {
}

computeSizes() {
let realHeight = this.content.offsetHeight;
let containerHeight = this.wrapper.offsetHeight;
let realWidth = this.content.offsetWidth;
let containerWidth = this.wrapper.offsetWidth;
let realHeight = this.content ? this.content.offsetHeight : 0;
let containerHeight = this.wrapper ? this.wrapper.offsetHeight : 0;
let realWidth = this.content ? this.content.offsetWidth : 0;
let containerWidth = this.content ? this.wrapper.offsetWidth : 0;

return {
realHeight: realHeight,
Expand Down