mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix Preact Forwarded Ref components not working in astro files when React integration is enabled (#9403)
* Fix Preact Forwarded Ref components not working in astro files when React integration is enabled
* Handle undefined $$typeof
* Add changeset
* Use Symbol.for
* ⚡
* Update .changeset/breezy-hairs-yell.md
---------
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
parent
1e984389ba
commit
7eb9fe8a71
2 changed files with 8 additions and 0 deletions
5
.changeset/breezy-hairs-yell.md
Normal file
5
.changeset/breezy-hairs-yell.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/react': patch
|
||||
---
|
||||
|
||||
Prevents unsupported `forwardRef` components created by Preact from being rendered by React
|
|
@ -23,6 +23,9 @@ async function check(Component, props, children) {
|
|||
}
|
||||
if (typeof Component !== 'function') return false;
|
||||
|
||||
// Preact forwarded-ref components can be functions, which React does not support
|
||||
if (typeof Component === 'function' && Component['$$typeof'] === Symbol.for('react.forward_ref')) return false;
|
||||
|
||||
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
|
||||
return React.Component.isPrototypeOf(Component) || React.PureComponent.isPrototypeOf(Component);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue