Skip to content

Commit

Permalink
Only forward defined refs
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jul 8, 2024
1 parent de80631 commit fd4eec0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/metal-boxes-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@emotion/primitives-core': patch
'@emotion/styled': patch
'@emotion/react': patch
---

Only forward defined `ref`s to improve compatibility with the upcoming React 19
5 changes: 3 additions & 2 deletions packages/primitives-core/src/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ export function createStyled(
newProps[key] = props[key]
}
}

newProps.style = [css.apply(mergedProps, styles), props.style]
newProps.ref = ref
if (ref) {
newProps.ref = ref
}

return React.createElement(finalTag, newProps)
})
Expand Down
4 changes: 3 additions & 1 deletion packages/react/src/emotion-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ let Emotion = /* #__PURE__ */ withEmotionCache(
newProps[key] = props[key]
}
}
newProps.ref = ref
newProps.className = className
if (ref) {
newProps.ref = ref
}

return (
<>
Expand Down
5 changes: 3 additions & 2 deletions packages/styled/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ let createStyled /*: CreateStyled */ = (
newProps[key] = props[key]
}
}

newProps.className = className
newProps.ref = ref
if (ref) {
newProps.ref = ref
}

return (
<>
Expand Down

0 comments on commit fd4eec0

Please sign in to comment.