/**1* Copyright 2013-2015, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule ReactComponentWithPureRenderMixin9*/1011'use strict';1213var shallowEqual = require("./shallowEqual");1415/**16* If your React component's render function is "pure", e.g. it will render the17* same result given the same props and state, provide this Mixin for a18* considerable performance boost.19*20* Most React components have pure render functions.21*22* Example:23*24* var ReactComponentWithPureRenderMixin =25* require('ReactComponentWithPureRenderMixin');26* React.createClass({27* mixins: [ReactComponentWithPureRenderMixin],28*29* render: function() {30* return <div className={this.props.className}>foo</div>;31* }32* });33*34* Note: This only checks shallow equality for props and state. If these contain35* complex data structures this mixin may have false-negatives for deeper36* differences. Only mixin to components which have simple props and state, or37* use `forceUpdate()` when you know deep data structures have changed.38*/39var ReactComponentWithPureRenderMixin = {40shouldComponentUpdate: function(nextProps, nextState) {41return !shallowEqual(this.props, nextProps) ||42!shallowEqual(this.state, nextState);43}44};4546module.exports = ReactComponentWithPureRenderMixin;474849