Skip to content

Commit

Permalink
Combine ReactJSXElementValidator with main module (facebook#28317)
Browse files Browse the repository at this point in the history
There are too many layers to the JSX runtime implementation. I think
basically everything should be implemented in a single file, so that's
what I'm going to do.

As a first step, this deletes ReactJSXElementValidator and moves all the
code into ReactJSXElement. I can already see how this will help us
remove more indirections in the future.

Next I'm going to do start moving the `createElement` runtime into this
module as well, since there's a lot of duplicated code.
  • Loading branch information
acdlite authored and AndyPengc12 committed Apr 15, 2024
1 parent 7f04b55 commit d068d43
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 466 deletions.
22 changes: 14 additions & 8 deletions packages/react/src/jsx/ReactJSX.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@
*/
import {REACT_FRAGMENT_TYPE} from 'shared/ReactSymbols';
import {
jsxWithValidationStatic,
jsxWithValidationDynamic,
jsxWithValidation,
} from './ReactJSXElementValidator';
import {jsx as jsxProd} from './ReactJSXElement';
const jsx: any = __DEV__ ? jsxWithValidationDynamic : jsxProd;
jsxProd,
jsxProdSignatureRunningInDevWithDynamicChildren,
jsxProdSignatureRunningInDevWithStaticChildren,
jsxDEV as _jsxDEV,
} from './ReactJSXElement';

const jsx: any = __DEV__
? jsxProdSignatureRunningInDevWithDynamicChildren
: jsxProd;
// we may want to special case jsxs internally to take advantage of static children.
// for now we can ship identical prod functions
const jsxs: any = __DEV__ ? jsxWithValidationStatic : jsxProd;
const jsxDEV: any = __DEV__ ? jsxWithValidation : undefined;
const jsxs: any = __DEV__
? jsxProdSignatureRunningInDevWithStaticChildren
: jsxProd;

const jsxDEV: any = __DEV__ ? _jsxDEV : undefined;

export {REACT_FRAGMENT_TYPE as Fragment, jsx, jsxs, jsxDEV};
Loading

0 comments on commit d068d43

Please sign in to comment.