diff --git a/src/renderers/shared/stack/reconciler/ReactReconciler.js b/src/renderers/shared/stack/reconciler/ReactReconciler.js index 3e5f1658ca8cf..fa672b7ef923f 100644 --- a/src/renderers/shared/stack/reconciler/ReactReconciler.js +++ b/src/renderers/shared/stack/reconciler/ReactReconciler.js @@ -13,6 +13,7 @@ var ReactRef = require('ReactRef'); var ReactInstrumentation = require('ReactInstrumentation'); +var shallowEqual = require('shallowEqual'); var warning = require('warning'); @@ -127,7 +128,7 @@ var ReactReconciler = { var prevElement = internalInstance._currentElement; if (nextElement === prevElement && - context === internalInstance._context + shallowEqual(context, internalInstance._context) ) { // Since elements are immutable after the owner is rendered, // we can do a cheap identity compare here to determine if this is a diff --git a/src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js b/src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js index 81777ace56d01..01f8c81192db1 100644 --- a/src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js +++ b/src/renderers/shared/stack/reconciler/__tests__/ReactCompositeComponent-test.js @@ -610,6 +610,40 @@ describe('ReactCompositeComponent', () => { expect(childRenders).toBe(1); }); + it('should skip update when rerendering element in container and the context is unchanged', () => { + var context = { foo: 'bar' }; + + class Parent extends React.Component { + static childContextTypes = { + foo: ReactPropTypes.string, + }; + + getChildContext() { + return context; + } + + render() { + return