Skip to content

Commit

Permalink
optimise jsx-runtime by only creating a new object when ref is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Apr 11, 2024
1 parent 8c88f52 commit 8524bb8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions jsx-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
// We'll want to preserve `ref` in props to get rid of the need for
// forwardRef components in the future, but that should happen via
// a separate PR.
let normalizedProps = {},
let normalizedProps = props || {},
ref,
i;
for (i in props) {
if (i == 'ref') {
ref = props[i];
} else {
normalizedProps[i] = props[i];
if (normalizedProps && (ref = normalizedProps.ref)) {
normalizedProps = {};
for (i in props) {
if (i != 'ref') {
normalizedProps[i] = props[i];
}
}
}

Expand Down

0 comments on commit 8524bb8

Please sign in to comment.