Skip to content

Commit

Permalink
Merge pull request #264 from brigade/pure
Browse files Browse the repository at this point in the history
Extend React.PureComponent instead of React.Component
  • Loading branch information
lencioni authored Jul 9, 2018
2 parents 8aa4e02 + a15c833 commit 5e3ec79
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/waypoint.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ const defaultProps = {
fireOnRapidScroll: true,
};

/**
* Calls a function when you scroll to the element.
*/
export default class Waypoint extends React.Component {
// React.PureComponent was added in React 15.3.0
const BaseClass = typeof React.PureComponent !== 'undefined' ?
React.PureComponent :
React.Component;

// Calls a function when you scroll to the element.
export default class Waypoint extends BaseClass {
constructor(props) {
super(props);

Expand Down

0 comments on commit 5e3ec79

Please sign in to comment.