Skip to content

Commit

Permalink
Use React.PureComponent instead of shallowCompare
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Apr 20, 2017
1 parent 4efa6fe commit c97501b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 35 deletions.
2 changes: 1 addition & 1 deletion dist/react-loader.css

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

2 changes: 1 addition & 1 deletion dist/react-loader.min.css

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

31 changes: 10 additions & 21 deletions docs/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25343,7 +25343,6 @@ module.exports = g;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

Expand All @@ -25359,10 +25358,6 @@ var _react = __webpack_require__("../node_modules/react/react.js");

var _react2 = _interopRequireDefault(_react);

var _reactAddonsShallowCompare = __webpack_require__("../node_modules/react-addons-shallow-compare/index.js");

var _reactAddonsShallowCompare2 = _interopRequireDefault(_reactAddonsShallowCompare);

var _classnames = __webpack_require__("../node_modules/classnames/index.js");

var _classnames2 = _interopRequireDefault(_classnames);
Expand All @@ -25383,29 +25378,24 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var _default = (_temp2 = _class = function (_Component) {
_inherits(_default, _Component);
var Loader = (_temp2 = _class = function (_PureComponent) {
_inherits(Loader, _PureComponent);

function _default() {
function Loader() {
var _ref;

var _temp, _this, _ret;

_classCallCheck(this, _default);
_classCallCheck(this, Loader);

for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = _default.__proto__ || Object.getPrototypeOf(_default)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this.actions = {}, _temp), _possibleConstructorReturn(_this, _ret);
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Loader.__proto__ || Object.getPrototypeOf(Loader)).call.apply(_ref, [this].concat(args))), _this), _this.state = {}, _this.actions = {}, _temp), _possibleConstructorReturn(_this, _ret);
}

_createClass(_default, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
return (0, _reactAddonsShallowCompare2.default)(this, nextProps, nextState);
}
}, {
_createClass(Loader, [{
key: 'render',
value: function render() {
var _props = this.props,
Expand All @@ -25426,16 +25416,15 @@ var _default = (_temp2 = _class = function (_Component) {
}
}]);

return _default;
}(_react.Component), _class.propTypes = {
return Loader;
}(_react.PureComponent), _class.propTypes = {
size: _propTypes2.default.oneOf(['lg', 'md', 'sm', 'large', 'medium', 'small']),
overlay: _propTypes2.default.bool
}, _class.defaultProps = {
size: 'md',
overlay: false
}, _temp2);

exports.default = _default;
exports.default = Loader;

/***/ }),

Expand Down Expand Up @@ -25816,4 +25805,4 @@ if(false) {
/***/ })

/******/ });
//# sourceMappingURL=bundle.js.map?c9059d7fef2666ee849e
//# sourceMappingURL=bundle.js.map?8110c2762482b0f1c6de
2 changes: 1 addition & 1 deletion docs/bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
</div>
</nav>
<div id="container"></div>
<script type="text/javascript" src="bundle.js?c9059d7fef2666ee849e"></script></body>
<script type="text/javascript" src="bundle.js?8110c2762482b0f1c6de"></script></body>
</html>
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trendmicro/react-loader",
"version": "0.5.2",
"version": "0.5.3",
"description": "Trend Micro Components: React Loader",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -48,11 +48,10 @@
},
"dependencies": {
"classnames": "^2.2.5",
"prop-types": "^15.5.8",
"react-addons-shallow-compare": "^0.14.0 || ^15.0.0"
"prop-types": "^15.5.8"
},
"devDependencies": {
"@trendmicro/react-buttons": "~1.0.3",
"@trendmicro/react-buttons": "~1.0.4",
"babel-cli": "~6.24.1",
"babel-core": "~6.24.1",
"babel-eslint": "~7.2.2",
Expand Down
10 changes: 4 additions & 6 deletions src/Loader.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import React, { PureComponent } from 'react';
import classNames from 'classnames';
import styles from './index.styl';

export default class extends Component {
class Loader extends PureComponent {
static propTypes = {
size: PropTypes.oneOf([
'lg',
Expand All @@ -26,9 +25,6 @@ export default class extends Component {
actions = {
};

shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
render() {
const {
size,
Expand Down Expand Up @@ -57,3 +53,5 @@ export default class extends Component {
);
}
}

export default Loader;

0 comments on commit c97501b

Please sign in to comment.