Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phased dispatcher #14701

Merged
merged 9 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import type {ReactContext, ReactProviderType} from 'shared/ReactTypes';
import type {Fiber} from 'react-reconciler/src/ReactFiber';
import type {Hook} from 'react-reconciler/src/ReactFiberHooks';
import typeof {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberDispatcher';
import type {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberHooks';

import ErrorStackParser from 'error-stack-parser';
import ReactSharedInternals from 'shared/ReactSharedInternals';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,21 +432,25 @@ describe('ReactDOMServerHooks', () => {
expect(domNode.textContent).toEqual('hi');
});

itRenders('with a warning for useRef inside useReducer', async render => {
function App() {
const [value, dispatch] = useReducer((state, action) => {
useRef(0);
return state + 1;
}, 0);
if (value === 0) {
dispatch();
itThrowsWhenRendering(
'with a warning for useRef inside useReducer',
async render => {
function App() {
const [value, dispatch] = useReducer((state, action) => {
useRef(0);
return state + 1;
}, 0);
if (value === 0) {
dispatch();
}
return value;
}
return value;
}

const domNode = await render(<App />, 1);
expect(domNode.textContent).toEqual('1');
});
const domNode = await render(<App />, 1);
expect(domNode.textContent).toEqual('1');
},
'Rendered more hooks than during the previous render',
);

itRenders('with a warning for useRef inside useState', async render => {
function App() {
Expand Down
5 changes: 4 additions & 1 deletion packages/react-dom/src/server/ReactPartialRendererHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import typeof {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberDispatcher';
import type {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberHooks';
import type {ThreadID} from './ReactThreadIDAllocator';
import type {ReactContext} from 'shared/ReactTypes';

Expand Down Expand Up @@ -113,6 +113,9 @@ function areHookInputsEqual(
}

function createHook(): Hook {
if (numberOfReRenders > 0) {
invariant(false, 'Rendered more hooks than during the previous render');
}
return {
memoizedState: null,
queue: null,
Expand Down
36 changes: 0 additions & 36 deletions packages/react-reconciler/src/ReactFiberDispatcher.js

This file was deleted.

Loading