Skip to content

Commit

Permalink
null scrollbar fix for componentWillUnmount
Browse files Browse the repository at this point in the history
In some cases, `componentWillUnmount` is called before `componentDidMount`, which leaves `this.scrollbar` as null and causes a `Cannot read property 'destroy' of null` error. [See this issue in React](facebook/react#5719)
  • Loading branch information
gesuvskn committed Apr 5, 2021
1 parent 62db778 commit cdce81f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module.exports = React.createClass({
},

componentWillUnmount() {
this.scrollbar.destroy();
if (this.scrollbar) {
this.scrollbar.destroy();
}
this.scrollbar = null;
},

Expand Down

0 comments on commit cdce81f

Please sign in to comment.