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 37f9fab commit 3afc543
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 47 deletions.
2 changes: 1 addition & 1 deletion dist/react-breadcrumbs.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-breadcrumbs.min.css

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

37 changes: 9 additions & 28 deletions docs/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -25067,7 +25067,7 @@ module.exports = g;

module.exports = {
"name": "@trendmicro/react-breadcrumbs",
"version": "0.5.2",
"version": "0.5.3",
"description": "Trend Micro Components: React Breadcrumbs",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -25116,8 +25116,7 @@ module.exports = {
},
"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-anchor": "~0.5.4",
Expand Down Expand Up @@ -25189,10 +25188,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 _index = __webpack_require__("../src/index.styl");

var _index2 = _interopRequireDefault(_index);
Expand All @@ -25207,8 +25202,8 @@ 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 Breadcrumbs = (_temp = _class = function (_Component) {
_inherits(Breadcrumbs, _Component);
var Breadcrumbs = (_temp = _class = function (_PureComponent) {
_inherits(Breadcrumbs, _PureComponent);

function Breadcrumbs() {
_classCallCheck(this, Breadcrumbs);
Expand All @@ -25217,11 +25212,6 @@ var Breadcrumbs = (_temp = _class = function (_Component) {
}

_createClass(Breadcrumbs, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
return (0, _reactAddonsShallowCompare2.default)(this, nextProps, nextState);
}
}, {
key: 'render',
value: function render() {
var _props = this.props,
Expand Down Expand Up @@ -25258,7 +25248,7 @@ var Breadcrumbs = (_temp = _class = function (_Component) {
}]);

return Breadcrumbs;
}(_react.Component), _class.propTypes = {
}(_react.PureComponent), _class.propTypes = {
showLineSeparator: _propTypes2.default.bool
}, _class.defaultProps = {
showLineSeparator: false
Expand Down Expand Up @@ -25295,10 +25285,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 _index = __webpack_require__("../src/index.styl");

var _index2 = _interopRequireDefault(_index);
Expand All @@ -25315,8 +25301,8 @@ 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 BreadcrumbsItem = (_temp = _class = function (_Component) {
_inherits(BreadcrumbsItem, _Component);
var BreadcrumbsItem = (_temp = _class = function (_PureComponent) {
_inherits(BreadcrumbsItem, _PureComponent);

function BreadcrumbsItem() {
_classCallCheck(this, BreadcrumbsItem);
Expand All @@ -25325,11 +25311,6 @@ var BreadcrumbsItem = (_temp = _class = function (_Component) {
}

_createClass(BreadcrumbsItem, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps, nextState) {
return (0, _reactAddonsShallowCompare2.default)(this, nextProps, nextState);
}
}, {
key: 'render',
value: function render() {
var _props = this.props,
Expand All @@ -25344,7 +25325,7 @@ var BreadcrumbsItem = (_temp = _class = function (_Component) {
}]);

return BreadcrumbsItem;
}(_react.Component), _class.propTypes = {
}(_react.PureComponent), _class.propTypes = {
active: _propTypes2.default.bool
}, _class.defaultProps = {
active: false
Expand Down Expand Up @@ -25615,4 +25596,4 @@ if(false) {
/***/ })

/******/ });
//# sourceMappingURL=bundle.js.map?a1671953f0b6aabaa35e
//# sourceMappingURL=bundle.js.map?ded80544df27ac40abbb
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 @@ -41,5 +41,5 @@
</div>
</nav>
<div id="container"></div>
<script type="text/javascript" src="bundle.js?a1671953f0b6aabaa35e"></script></body>
<script type="text/javascript" src="bundle.js?ded80544df27ac40abbb"></script></body>
</html>
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trendmicro/react-breadcrumbs",
"version": "0.5.2",
"version": "0.5.3",
"description": "Trend Micro Components: React Breadcrumbs",
"main": "lib/index.js",
"files": [
Expand Down Expand Up @@ -49,8 +49,7 @@
},
"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-anchor": "~0.5.4",
Expand Down
8 changes: 2 additions & 6 deletions src/Breadcrumbs.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { Component, cloneElement } from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import React, { PureComponent, cloneElement } from 'react';
import styles from './index.styl';

class Breadcrumbs extends Component {
class Breadcrumbs extends PureComponent {
static propTypes = {
showLineSeparator: PropTypes.bool
};
static defaultProps = {
showLineSeparator: false
};

shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
render() {
const {
children,
Expand Down
8 changes: 2 additions & 6 deletions src/BreadcrumbsItem.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import shallowCompare from 'react-addons-shallow-compare';
import React, { PureComponent } from 'react';
import styles from './index.styl';

class BreadcrumbsItem extends Component {
class BreadcrumbsItem extends PureComponent {
static propTypes = {
active: PropTypes.bool
};
static defaultProps = {
active: false
};

shouldComponentUpdate(nextProps, nextState) {
return shallowCompare(this, nextProps, nextState);
}
render() {
const {
className,
Expand Down

0 comments on commit 3afc543

Please sign in to comment.