Files
tubestation/devtools/client/responsive.html/components/browser.js
J. Ryan Stinnett 08a9307352 Bug 1253781 - Better perf with pure render. r=gl
There are few easy wins that greatly improve our perf with React:

* Add the PureRenderMixin to pure components that always render the same thing
  given the same props and state.  This implements React's shouldComponentUpdate
  as a shallow equality check of the props and state, so render() will be
  skipped if they match the previous values.
* Change action dispatch functions so they are only created once instead of on
  each render().  If an outer component creates new functions for each render()
  call, then the PureRenderMixin equality check fails for only the new function
  instances, even though no data has changed.

MozReview-Commit-ID: D96X048nEF4
2016-03-07 12:00:43 -06:00

49 lines
980 B
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { DOM: dom, createClass, PropTypes, addons } =
require("devtools/client/shared/vendor/react");
const Types = require("../types");
module.exports = createClass({
displayName: "Browser",
mixins: [ addons.PureRenderMixin ],
propTypes: {
location: Types.location.isRequired,
width: Types.viewport.width.isRequired,
height: Types.viewport.height.isRequired,
isResizing: PropTypes.bool.isRequired,
},
render() {
let {
location,
width,
height,
isResizing,
} = this.props;
let className = "browser";
if (isResizing) {
className += " resizing";
}
return dom.iframe(
{
className,
src: location,
width,
height,
}
);
},
});