Skip to content

Commit

Permalink
Replace react-addons-shallow-compare (#123)
Browse files Browse the repository at this point in the history
`react-addons-shallow-compare` is deprecated.

Keep the original `shouldComponentUpdate` for checking  `shouldFreeze` flag

should address #87
  • Loading branch information
roderickhsiao authored and redonkulus committed Jan 15, 2019
1 parent 9decc49 commit e4668b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-stickynode",
"version": "2.1.0",
"version": "2.1.1",
"description": "A performant and comprehensive React sticky",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"dependencies": {
"classnames": "^2.0.0",
"prop-types": "^15.6.0",
"react-addons-shallow-compare": "^0.14.2 || ^15.0.0",
"shallowequal": "^1.0.0",
"subscribe-ui-event": "^2.0.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/Sticky.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import PropTypes from 'prop-types'

import {subscribe} from 'subscribe-ui-event';
import classNames from 'classnames';
import shallowCompare from 'react-addons-shallow-compare';
import shallowEqual from 'shallowequal';

// constants
const STATUS_ORIGINAL = 0; // The default status, locating at the original position.
Expand Down Expand Up @@ -356,7 +356,7 @@ class Sticky extends Component {
}

shouldComponentUpdate (nextProps, nextState) {
return !this.props.shouldFreeze() && shallowCompare(this, nextProps, nextState);
return !this.props.shouldFreeze() && !(shallowEqual(this.props, nextProps) && shallowEqual(this.state, nextState));
}

render () {
Expand Down

0 comments on commit e4668b5

Please sign in to comment.