diff --git a/src/isomorphic/classic/class/__tests__/ReactClass-test.js b/src/isomorphic/classic/class/__tests__/ReactClass-test.js index b9558f83b912b..cce8554965fcf 100644 --- a/src/isomorphic/classic/class/__tests__/ReactClass-test.js +++ b/src/isomorphic/classic/class/__tests__/ReactClass-test.js @@ -362,23 +362,4 @@ describe('ReactClass-spec', function() { ); }); - it('warns when calling getDOMNode', function() { - var MyComponent = React.createClass({ - render: function() { - return
; - }, - }); - - var container = document.createElement('div'); - var instance = ReactDOM.render(, container); - - instance.getDOMNode(); - - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( - 'MyComponent.getDOMNode(...) is deprecated. Please use ' + - 'ReactDOM.findDOMNode(instance) instead.' - ); - }); - }); diff --git a/src/isomorphic/modern/class/ReactComponent.js b/src/isomorphic/modern/class/ReactComponent.js index 0632106ca5169..2882b56602d8c 100644 --- a/src/isomorphic/modern/class/ReactComponent.js +++ b/src/isomorphic/modern/class/ReactComponent.js @@ -106,10 +106,6 @@ ReactComponent.prototype.forceUpdate = function(callback) { */ if (__DEV__) { var deprecatedAPIs = { - getDOMNode: [ - 'getDOMNode', - 'Use ReactDOM.findDOMNode(component) instead.', - ], isMounted: [ 'isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + diff --git a/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee b/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee index a712152090fe1..e7b1f574c579a 100644 --- a/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee +++ b/src/isomorphic/modern/class/__tests__/ReactCoffeeScriptClass-test.coffee @@ -345,19 +345,15 @@ describe 'ReactCoffeeScriptClass', -> spyOn console, 'error' instance = test Inner(name: 'foo'), 'DIV', 'foo' - expect(-> instance.getDOMNode()).toThrow() expect(-> instance.replaceState {}).toThrow() expect(-> instance.isMounted()).toThrow() expect(-> instance.setProps name: 'bar').toThrow() expect(-> instance.replaceProps name: 'bar').toThrow() - expect(console.error.calls.length).toBe 3 + expect(console.error.calls.length).toBe 2 expect(console.error.argsForCall[0][0]).toContain( - 'getDOMNode(...) is deprecated in plain JavaScript React classes' - ) - expect(console.error.argsForCall[1][0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ) - expect(console.error.argsForCall[2][0]).toContain( + expect(console.error.argsForCall[1][0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ) diff --git a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js index 3fc043bb10a19..dfd235f22ec23 100644 --- a/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js +++ b/src/isomorphic/modern/class/__tests__/ReactES6Class-test.js @@ -402,20 +402,15 @@ describe('ReactES6Class', function() { it('should throw AND warn when trying to access classic APIs', function() { spyOn(console, 'error'); var instance = test(, 'DIV', 'foo'); - expect(() => instance.getDOMNode()).toThrow(); expect(() => instance.replaceState({})).toThrow(); expect(() => instance.isMounted()).toThrow(); expect(() => instance.setProps({name: 'bar'})).toThrow(); expect(() => instance.replaceProps({name: 'bar'})).toThrow(); - expect(console.error.calls.length).toBe(3); + expect(console.error.calls.length).toBe(2); expect(console.error.argsForCall[0][0]).toContain( - 'getDOMNode(...) is deprecated in plain JavaScript React classes. ' + - 'Use ReactDOM.findDOMNode(component) instead.' - ); - expect(console.error.argsForCall[1][0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ); - expect(console.error.argsForCall[2][0]).toContain( + expect(console.error.argsForCall[1][0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ); }); diff --git a/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts b/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts index 0b89ed260c0d4..a1d1470cd5ffa 100644 --- a/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts +++ b/src/isomorphic/modern/class/__tests__/ReactTypeScriptClass-test.ts @@ -486,19 +486,15 @@ describe('ReactTypeScriptClass', function() { React.createElement(Inner, {name: 'foo'}), 'DIV','foo' ); - expect(() => instance.getDOMNode()).toThrow(); expect(() => instance.replaceState({})).toThrow(); expect(() => instance.isMounted()).toThrow(); expect(() => instance.setProps({ name: 'bar' })).toThrow(); expect(() => instance.replaceProps({ name: 'bar' })).toThrow(); - expect((console.error).argsForCall.length).toBe(3); + expect((console.error).argsForCall.length).toBe(2); expect((console.error).argsForCall[0][0]).toContain( - 'getDOMNode(...) is deprecated in plain JavaScript React classes' - ); - expect((console.error).argsForCall[1][0]).toContain( 'replaceState(...) is deprecated in plain JavaScript React classes' ); - expect((console.error).argsForCall[2][0]).toContain( + expect((console.error).argsForCall[1][0]).toContain( 'isMounted(...) is deprecated in plain JavaScript React classes' ); }); diff --git a/src/renderers/dom/client/findDOMNode.js b/src/renderers/dom/client/findDOMNode.js index c2aadf20a29f0..65c80700938a7 100644 --- a/src/renderers/dom/client/findDOMNode.js +++ b/src/renderers/dom/client/findDOMNode.js @@ -31,7 +31,7 @@ function findDOMNode(componentOrElement) { if (owner !== null) { warning( owner._warnedAboutRefsInRender, - '%s is accessing getDOMNode or findDOMNode inside its render(). ' + + '%s is accessing findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + diff --git a/src/renderers/dom/shared/ReactBrowserComponentMixin.js b/src/renderers/dom/shared/ReactBrowserComponentMixin.js deleted file mode 100644 index 091672746969c..0000000000000 --- a/src/renderers/dom/shared/ReactBrowserComponentMixin.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * @providesModule ReactBrowserComponentMixin - */ - -'use strict'; - -var ReactInstanceMap = require('ReactInstanceMap'); - -var findDOMNode = require('findDOMNode'); -var warning = require('warning'); - -var didWarnKey = '_getDOMNodeDidWarn'; - -var ReactBrowserComponentMixin = { - /** - * Returns the DOM node rendered by this component. - * - * @return {DOMElement} The root node of this component. - * @final - * @protected - */ - getDOMNode: function() { - warning( - this.constructor[didWarnKey], - '%s.getDOMNode(...) is deprecated. Please use ' + - 'ReactDOM.findDOMNode(instance) instead.', - ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown' - ); - this.constructor[didWarnKey] = true; - return findDOMNode(this); - }, -}; - -module.exports = ReactBrowserComponentMixin; diff --git a/src/renderers/dom/shared/ReactDefaultInjection.js b/src/renderers/dom/shared/ReactDefaultInjection.js index 90f207b627c36..09cbf25e485f9 100644 --- a/src/renderers/dom/shared/ReactDefaultInjection.js +++ b/src/renderers/dom/shared/ReactDefaultInjection.js @@ -17,7 +17,6 @@ var DefaultEventPluginOrder = require('DefaultEventPluginOrder'); var EnterLeaveEventPlugin = require('EnterLeaveEventPlugin'); var ExecutionEnvironment = require('ExecutionEnvironment'); var HTMLDOMPropertyConfig = require('HTMLDOMPropertyConfig'); -var ReactBrowserComponentMixin = require('ReactBrowserComponentMixin'); var ReactComponentBrowserEnvironment = require('ReactComponentBrowserEnvironment'); var ReactDOMComponent = require('ReactDOMComponent'); @@ -75,8 +74,6 @@ function inject() { ReactDOMTextComponent ); - ReactInjection.Class.injectMixin(ReactBrowserComponentMixin); - ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig); ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig); diff --git a/src/renderers/shared/reconciler/__tests__/ReactComponent-test.js b/src/renderers/shared/reconciler/__tests__/ReactComponent-test.js index 22ca506725797..444bedddb8098 100644 --- a/src/renderers/shared/reconciler/__tests__/ReactComponent-test.js +++ b/src/renderers/shared/reconciler/__tests__/ReactComponent-test.js @@ -265,26 +265,6 @@ describe('ReactComponent', function() { expect(callback.mock.calls.length).toBe(3); }); - it('warns when calling getDOMNode', function() { - spyOn(console, 'error'); - - var Potato = React.createClass({ - render: function() { - return
; - }, - }); - var container = document.createElement('div'); - var instance = ReactDOM.render(, container); - - instance.getDOMNode(); - - expect(console.error.calls.length).toBe(1); - expect(console.error.argsForCall[0][0]).toContain( - 'Potato.getDOMNode(...) is deprecated. Please use ' + - 'ReactDOM.findDOMNode(instance) instead.' - ); - }); - it('throws usefully when rendering badly-typed elements', function() { spyOn(console, 'error'); diff --git a/src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js b/src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js index 3b938fa06e68d..b7204eb9a9e19 100644 --- a/src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js +++ b/src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js @@ -322,7 +322,7 @@ describe('ReactComponentLifeCycle', function() { ReactTestUtils.renderIntoDocument(); expect(console.error.argsForCall.length).toBe(1); expect(console.error.argsForCall[0][0]).toContain( - 'Component is accessing getDOMNode or findDOMNode inside its render()' + 'Component is accessing findDOMNode inside its render()' ); }); diff --git a/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js b/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js index 0bcb65149189a..e39184c44b6ad 100644 --- a/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js +++ b/src/renderers/shared/reconciler/__tests__/ReactCompositeComponent-test.js @@ -1073,21 +1073,11 @@ describe('ReactCompositeComponent', function() { expect(ReactDOM.findDOMNode(comp.refs.static0).textContent).toBe('A'); expect(ReactDOM.findDOMNode(comp.refs.static1).textContent).toBe('B'); - expect(ReactDOM.findDOMNode(comp.refs.static0)) - .toBe(comp.refs.static0.getDOMNode()); - expect(ReactDOM.findDOMNode(comp.refs.static1)) - .toBe(comp.refs.static1.getDOMNode()); - // When flipping the order, the refs should update even though the actual // contents do not ReactDOM.render(, container); expect(ReactDOM.findDOMNode(comp.refs.static0).textContent).toBe('B'); expect(ReactDOM.findDOMNode(comp.refs.static1).textContent).toBe('A'); - - expect(ReactDOM.findDOMNode(comp.refs.static0)) - .toBe(comp.refs.static0.getDOMNode()); - expect(ReactDOM.findDOMNode(comp.refs.static1)) - .toBe(comp.refs.static1.getDOMNode()); }); it('should allow access to findDOMNode in componentWillUnmount', function() { @@ -1096,11 +1086,11 @@ describe('ReactCompositeComponent', function() { var Component = React.createClass({ componentDidMount: function() { a = ReactDOM.findDOMNode(this); - expect(a).toBe(this.getDOMNode()); + expect(a).not.toBe(null); }, componentWillUnmount: function() { b = ReactDOM.findDOMNode(this); - expect(b).toBe(this.getDOMNode()); + expect(b).not.toBe(null); }, render: function() { return
; diff --git a/src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js b/src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js index 116fb914c1a11..98d5354e2053b 100644 --- a/src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js +++ b/src/renderers/shared/reconciler/__tests__/ReactEmptyComponent-test.js @@ -158,7 +158,7 @@ describe('ReactEmptyComponent', function() { } ); - it('should have getDOMNode return null when multiple layers of composite ' + + it('should have findDOMNode return null when multiple layers of composite ' + 'components render to the same null placeholder', () => { var GrandChild = React.createClass({ diff --git a/src/test/__tests__/ReactTestUtils-test.js b/src/test/__tests__/ReactTestUtils-test.js index 2b044d7d2eb21..eef20cc22fed8 100644 --- a/src/test/__tests__/ReactTestUtils-test.js +++ b/src/test/__tests__/ReactTestUtils-test.js @@ -352,33 +352,6 @@ describe('ReactTestUtils', function() { expect(log).toEqual(['orangepurple', 'orange', 'purple']); }); - it('does not warn for getDOMNode on ES6 classes', function() { - var Foo = React.createClass({ - render: function() { - return
; - }, - }); - - class Bar extends React.Component { - render() { - return
; - } - } - - spyOn(console, 'error'); - - var foo = ReactTestUtils.renderIntoDocument(); - expect(ReactTestUtils.isDOMComponent(foo)).toBe(false); - - var bar = ReactTestUtils.renderIntoDocument(); - expect(ReactTestUtils.isDOMComponent(bar)).toBe(false); - - var div = ReactTestUtils.renderIntoDocument(
); - expect(ReactTestUtils.isDOMComponent(div)).toBe(true); - - expect(console.error.calls.length).toBe(0); - }); - it('should support injected wrapper components as DOM components', function() { var getTestDocument = require('getTestDocument');