Skip to content

Commit

Permalink
Create Error/Task in the top level calls for jsxProdSignatureRunningI…
Browse files Browse the repository at this point in the history
…nDev

To do this we need to break out the jsxDEV implementation into a helper.
  • Loading branch information
sebmarkbage committed May 22, 2024
1 parent d168950 commit 67c9f7d
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions packages/react/src/jsx/ReactJSXElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,16 @@ export function jsxProdSignatureRunningInDevWithDynamicChildren(
) {
if (__DEV__) {
const isStaticChildren = false;
return jsxDEV(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
__DEV__ && enableOwnerStacks ? Error('react-stack-top-frame') : undefined,
__DEV__ && enableOwnerStacks ? createTask(getTaskName(type)) : undefined,
);
}
}

Expand All @@ -505,7 +514,16 @@ export function jsxProdSignatureRunningInDevWithStaticChildren(
) {
if (__DEV__) {
const isStaticChildren = true;
return jsxDEV(type, config, maybeKey, isStaticChildren, source, self);
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
__DEV__ && enableOwnerStacks ? Error('react-stack-top-frame') : undefined,
__DEV__ && enableOwnerStacks ? createTask(getTaskName(type)) : undefined,
);
}
}

Expand All @@ -518,6 +536,28 @@ const didWarnAboutKeySpread = {};
* @param {string} key
*/
export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
return jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
__DEV__ && enableOwnerStacks ? Error('react-stack-top-frame') : undefined,
__DEV__ && enableOwnerStacks ? createTask(getTaskName(type)) : undefined,
);
}

function jsxDEVImpl(
type,
config,
maybeKey,
isStaticChildren,
source,
self,
debugStack,
debugTask,
) {
if (__DEV__) {
if (!isValidElementType(type)) {
// This is an invalid element type.
Expand Down Expand Up @@ -716,8 +756,8 @@ export function jsxDEV(type, config, maybeKey, isStaticChildren, source, self) {
source,
getOwner(),
props,
__DEV__ && enableOwnerStacks ? Error('react-stack-top-frame') : undefined,
__DEV__ && enableOwnerStacks ? createTask(getTaskName(type)) : undefined,
debugStack,
debugTask,
);
}
}
Expand Down

0 comments on commit 67c9f7d

Please sign in to comment.