Skip to content

Commit ec0e8b0

Browse files
committed
Move createElement resolution out of entry module
The implementation of createElement is different in production and development. This moves the DEV check out of the entry module and into the ReactElement module. There was already a TODO comment for this; I'm doing it now because I'm about to refactor the server entry module (ReactServer.js) to import createElement directly instead of going through the client entry module (React.js, which I'll also probably rename to ReactClient.js).
1 parent 5d1b15a commit ec0e8b0

File tree

4 files changed

+604
-587
lines changed

4 files changed

+604
-587
lines changed

packages/react/src/React.js

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import {Component, PureComponent} from './ReactBaseClasses';
2626
import {createRef} from './ReactCreateRef';
2727
import {forEach, map, count, toArray, only} from './ReactChildren';
2828
import {
29-
createElement as createElementProd,
30-
createFactory as createFactoryProd,
31-
cloneElement as cloneElementProd,
29+
createElement,
30+
createFactory,
31+
cloneElement,
3232
isValidElement,
3333
} from './ReactElement';
3434
import {createContext} from './ReactContext';
@@ -61,27 +61,12 @@ import {
6161
useMemoCache,
6262
useOptimistic,
6363
} from './ReactHooks';
64-
import {
65-
createElementWithValidation,
66-
createFactoryWithValidation,
67-
cloneElementWithValidation,
68-
} from './ReactElementValidator';
64+
6965
import {createServerContext} from './ReactServerContext';
7066
import ReactSharedInternals from './ReactSharedInternalsClient';
7167
import {startTransition} from './ReactStartTransition';
7268
import {act} from './ReactAct';
7369

74-
// TODO: Move this branching into the other module instead and just re-export.
75-
const createElement: any = __DEV__
76-
? createElementWithValidation
77-
: createElementProd;
78-
const cloneElement: any = __DEV__
79-
? cloneElementWithValidation
80-
: cloneElementProd;
81-
const createFactory: any = __DEV__
82-
? createFactoryWithValidation
83-
: createFactoryProd;
84-
8570
const Children = {
8671
map,
8772
forEach,

0 commit comments

Comments
 (0)