Skip to content

Commit c8e5088

Browse files
committed
Slot: Fix React Element type check for lazy components
Co-authored-by: Jenna Smith <jjenzz@users.noreply.github.com> The `React.isValidElement(element)` check in `isLazyComponent` returned `false` for lazy elements in a NextJS prod build (unclear yet if this is just a Next thing or an issue with the prod build of React). Changing the check to `'$$typeof' in element` fixes it.
1 parent e98cb92 commit c8e5088

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/react/slot/src/slot.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ function isPromiseLike(value: unknown): value is PromiseLike<unknown> {
3131

3232
function isLazyComponent(element: React.ReactNode): element is LazyReactElement {
3333
return (
34-
React.isValidElement(element) &&
34+
element != null &&
35+
typeof element === 'object' &&
36+
'$$typeof' in element &&
3537
element.$$typeof === REACT_LAZY_TYPE &&
3638
'_payload' in element &&
3739
isPromiseLike(element._payload)

0 commit comments

Comments
 (0)