diff --git a/src/isomorphic/hooks/ReactComponentTreeHook.js b/src/isomorphic/hooks/ReactComponentTreeHook.js index 1a934f5fab..97aa9fa23b 100644 --- a/src/isomorphic/hooks/ReactComponentTreeHook.js +++ b/src/isomorphic/hooks/ReactComponentTreeHook.js @@ -86,7 +86,7 @@ var ReactComponentTreeHook = { var nextChild = tree[nextChildID]; invariant( nextChild, - 'Expected devtool events to fire for the child ' + + 'Expected hook events to fire for the child ' + 'before its parent includes it in onSetChildren().' ); invariant( diff --git a/src/renderers/dom/client/ReactMount.js b/src/renderers/dom/client/ReactMount.js index 9a0d15ba27..42c4a676f9 100644 --- a/src/renderers/dom/client/ReactMount.js +++ b/src/renderers/dom/client/ReactMount.js @@ -302,7 +302,7 @@ var ReactMount = { }, /** - * Render a new component into the DOM. Hooked by devtools! + * Render a new component into the DOM. Hooked by hooks! * * @param {ReactElement} nextElement element to render * @param {DOMElement} container container to render into diff --git a/src/renderers/dom/shared/ReactDOMDebugTool.js b/src/renderers/dom/shared/ReactDOMDebugTool.js index 99589e7cdc..dbbd5a1a79 100644 --- a/src/renderers/dom/shared/ReactDOMDebugTool.js +++ b/src/renderers/dom/shared/ReactDOMDebugTool.js @@ -29,7 +29,7 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) { } catch (e) { warning( handlerDoesThrowForEvent[handlerFunctionName], - 'exception thrown by devtool while handling %s: %s', + 'exception thrown by hook while handling %s: %s', handlerFunctionName, e + '\n' + e.stack ); @@ -39,14 +39,14 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) { } var ReactDOMDebugTool = { - addDevtool(devtool) { - ReactDebugTool.addDevtool(devtool); - eventHandlers.push(devtool); + addHook(hook) { + ReactDebugTool.addHook(hook); + eventHandlers.push(hook); }, - removeDevtool(devtool) { - ReactDebugTool.removeDevtool(devtool); + removeHook(hook) { + ReactDebugTool.removeHook(hook); for (var i = 0; i < eventHandlers.length; i++) { - if (eventHandlers[i] === devtool) { + if (eventHandlers[i] === hook) { eventHandlers.splice(i, 1); i--; } @@ -66,7 +66,7 @@ var ReactDOMDebugTool = { }, }; -ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyHook); -ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropHook); +ReactDOMDebugTool.addHook(ReactDOMUnknownPropertyHook); +ReactDOMDebugTool.addHook(ReactDOMNullInputValuePropHook); module.exports = ReactDOMDebugTool; diff --git a/src/renderers/dom/shared/__tests__/ReactDOMDebugTool-test.js b/src/renderers/dom/shared/__tests__/ReactDOMDebugTool-test.js index a8fdd92175..3e60e2807d 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMDebugTool-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMDebugTool-test.js @@ -19,13 +19,13 @@ describe('ReactDOMDebugTool', function() { ReactDOMDebugTool = require('ReactDOMDebugTool'); }); - it('should add and remove devtools', () => { + it('should add and remove hooks', () => { var handler1 = jasmine.createSpy('spy'); var handler2 = jasmine.createSpy('spy'); - var devtool1 = {onTestEvent: handler1}; - var devtool2 = {onTestEvent: handler2}; + var hook1 = {onTestEvent: handler1}; + var hook2 = {onTestEvent: handler2}; - ReactDOMDebugTool.addDevtool(devtool1); + ReactDOMDebugTool.addHook(hook1); ReactDOMDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(1); expect(handler2.calls.count()).toBe(0); @@ -34,7 +34,7 @@ describe('ReactDOMDebugTool', function() { expect(handler1.calls.count()).toBe(2); expect(handler2.calls.count()).toBe(0); - ReactDOMDebugTool.addDevtool(devtool2); + ReactDOMDebugTool.addHook(hook2); ReactDOMDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(3); expect(handler2.calls.count()).toBe(1); @@ -43,20 +43,20 @@ describe('ReactDOMDebugTool', function() { expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(2); - ReactDOMDebugTool.removeDevtool(devtool1); + ReactDOMDebugTool.removeHook(hook1); ReactDOMDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(3); - ReactDOMDebugTool.removeDevtool(devtool2); + ReactDOMDebugTool.removeHook(hook2); ReactDOMDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(3); }); - it('warns once when an error is thrown in devtool', () => { + it('warns once when an error is thrown in hook', () => { spyOn(console, 'error'); - ReactDOMDebugTool.addDevtool({ + ReactDOMDebugTool.addHook({ onTestEvent() { throw new Error('Hi.'); }, @@ -65,7 +65,7 @@ describe('ReactDOMDebugTool', function() { ReactDOMDebugTool.onTestEvent(); expect(console.error.calls.count()).toBe(1); expect(console.error.calls.argsFor(0)[0]).toContain( - 'exception thrown by devtool while handling ' + + 'exception thrown by hook while handling ' + 'onTestEvent: Error: Hi.' ); diff --git a/src/renderers/shared/ReactDebugTool.js b/src/renderers/shared/ReactDebugTool.js index 1b82cabe4b..20a27651c6 100644 --- a/src/renderers/shared/ReactDebugTool.js +++ b/src/renderers/shared/ReactDebugTool.js @@ -32,7 +32,7 @@ function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) { } catch (e) { warning( handlerDoesThrowForEvent[handlerFunctionName], - 'exception thrown by devtool while handling %s: %s', + 'exception thrown by hook while handling %s: %s', handlerFunctionName, e + '\n' + e.stack ); @@ -182,12 +182,12 @@ function resumeCurrentLifeCycleTimer() { } var ReactDebugTool = { - addDevtool(devtool) { - eventHandlers.push(devtool); + addHook(hook) { + eventHandlers.push(hook); }, - removeDevtool(devtool) { + removeHook(hook) { for (var i = 0; i < eventHandlers.length; i++) { - if (eventHandlers[i] === devtool) { + if (eventHandlers[i] === hook) { eventHandlers.splice(i, 1); i--; } @@ -204,7 +204,7 @@ var ReactDebugTool = { isProfiling = true; flushHistory.length = 0; resetMeasurements(); - ReactDebugTool.addDevtool(ReactHostOperationHistoryHook); + ReactDebugTool.addHook(ReactHostOperationHistoryHook); }, endProfiling() { if (!isProfiling) { @@ -213,7 +213,7 @@ var ReactDebugTool = { isProfiling = false; resetMeasurements(); - ReactDebugTool.removeDevtool(ReactHostOperationHistoryHook); + ReactDebugTool.removeHook(ReactHostOperationHistoryHook); }, getFlushHistory() { return flushHistory; @@ -325,9 +325,9 @@ var ReactDebugTool = { }, }; -ReactDebugTool.addDevtool(ReactInvalidSetStateWarningHook); -ReactDebugTool.addDevtool(ReactComponentTreeHook); -ReactDebugTool.addDevtool(ReactChildrenMutationWarningHook); +ReactDebugTool.addHook(ReactInvalidSetStateWarningHook); +ReactDebugTool.addHook(ReactComponentTreeHook); +ReactDebugTool.addHook(ReactChildrenMutationWarningHook); var url = (ExecutionEnvironment.canUseDOM && window.location.href) || ''; if ((/[?&]react_perf\b/).test(url)) { ReactDebugTool.beginProfiling(); diff --git a/src/renderers/shared/__tests__/ReactDebugTool-test.js b/src/renderers/shared/__tests__/ReactDebugTool-test.js index 15efcb5d1e..0eb809cdbc 100644 --- a/src/renderers/shared/__tests__/ReactDebugTool-test.js +++ b/src/renderers/shared/__tests__/ReactDebugTool-test.js @@ -19,13 +19,13 @@ describe('ReactDebugTool', function() { ReactDebugTool = require('ReactDebugTool'); }); - it('should add and remove devtools', () => { + it('should add and remove hooks', () => { var handler1 = jasmine.createSpy('spy'); var handler2 = jasmine.createSpy('spy'); - var devtool1 = {onTestEvent: handler1}; - var devtool2 = {onTestEvent: handler2}; + var hook1 = {onTestEvent: handler1}; + var hook2 = {onTestEvent: handler2}; - ReactDebugTool.addDevtool(devtool1); + ReactDebugTool.addHook(hook1); ReactDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(1); expect(handler2.calls.count()).toBe(0); @@ -34,7 +34,7 @@ describe('ReactDebugTool', function() { expect(handler1.calls.count()).toBe(2); expect(handler2.calls.count()).toBe(0); - ReactDebugTool.addDevtool(devtool2); + ReactDebugTool.addHook(hook2); ReactDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(3); expect(handler2.calls.count()).toBe(1); @@ -43,20 +43,20 @@ describe('ReactDebugTool', function() { expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(2); - ReactDebugTool.removeDevtool(devtool1); + ReactDebugTool.removeHook(hook1); ReactDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(3); - ReactDebugTool.removeDevtool(devtool2); + ReactDebugTool.removeHook(hook2); ReactDebugTool.onTestEvent(); expect(handler1.calls.count()).toBe(4); expect(handler2.calls.count()).toBe(3); }); - it('warns once when an error is thrown in devtool', () => { + it('warns once when an error is thrown in hook', () => { spyOn(console, 'error'); - ReactDebugTool.addDevtool({ + ReactDebugTool.addHook({ onTestEvent() { throw new Error('Hi.'); }, @@ -65,7 +65,7 @@ describe('ReactDebugTool', function() { ReactDebugTool.onTestEvent(); expect(console.error.calls.count()).toBe(1); expect(console.error.calls.argsFor(0)[0]).toContain( - 'exception thrown by devtool while handling ' + + 'exception thrown by hook while handling ' + 'onTestEvent: Error: Hi.' ); diff --git a/src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js b/src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js index 1c2e547eaf..28f3d931a1 100644 --- a/src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js +++ b/src/renderers/shared/hooks/__tests__/ReactComponentTreeHook-test.js @@ -87,7 +87,7 @@ describe('ReactComponentTreeHook', () => { ReactDOMServer.renderToString(); expectWrapperTreeToEqual(null); - // To test it, we tell the devtool to ignore next purge + // To test it, we tell the hook to ignore next purge // so the cleanup request by ReactDebugTool is ignored. // This lets us make assertions on the actual tree. ReactComponentTreeHook._preventPurging = true; diff --git a/src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js b/src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js index 37c21db22c..c3e8d17735 100644 --- a/src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js +++ b/src/renderers/shared/hooks/__tests__/ReactHostOperationHistoryHook-test.js @@ -86,7 +86,7 @@ describe('ReactHostOperationHistoryHook', () => { ReactHostOperationHistoryHook._preventClearing = true; ReactDOM.render(, node); - // Empty DOM components should be invisible to devtools. + // Empty DOM components should be invisible to hooks. assertHistoryMatches([]); }); @@ -106,7 +106,7 @@ describe('ReactHostOperationHistoryHook', () => { ReactDOM.render(, node); var inst = ReactDOMComponentTree.getInstanceFromNode(node.firstChild); - // Since empty components should be invisible to devtools, + // Since empty components should be invisible to hooks, // we record a "mount" event rather than a "replace with". assertHistoryMatches([{ instanceID: inst._debugID,