Skip to content

Commit fe67c16

Browse files
authored
Phased dispatcher (#14701)
* Move DEV-only function right above where it's used I don't like looking at this top-level function #petty * Use different dispatchers for functions & classes Classes support readContext, but not any of the other dispatcher methods. Function support all methods. This is a more robust version of our previous strategy of checking whether `currentlyRenderingFiber` is null. As a next step, we can use a separate dispatcher for each phase of the render cycle (mount versus update). * Use separate dispatchers for mount and update * Remove mount code from update path Deletes mount-specific code from the update path, since it should be unreachable. To continue supporting progressive enhancement (mounting new hooks at the end of the list), we detect when there are no more current hooks and switch back to the mount dispatcher. Progressive enhancement isn't officially supported yet, so it will continue to warn. * Factoring nits * Fix Flow Had to cheat more than I would like * More Flow nits * Switch back to using a special dispatcher for nested hooks in DEV In order for this strategy to work, I had to revert progressive enhancement support (appending hooks to the end). It was previously a warning but now it results in an error. We'll reconsider later. * Always pass args to updateState and updateReducer Even though the extra args are only used on mount, to ensure type consistency.
1 parent f970487 commit fe67c16

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ReactShallowRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import ReactSharedInternals from 'shared/ReactSharedInternals';
1818
import warning from 'shared/warning';
1919
import is from 'shared/objectIs';
2020

21-
import typeof {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberDispatcher';
21+
import type {Dispatcher as DispatcherType} from 'react-reconciler/src/ReactFiberHooks';
2222
import type {ReactContext} from 'shared/ReactTypes';
2323
import type {ReactElement} from 'shared/ReactElementType';
2424

0 commit comments

Comments
 (0)