Skip to content

Commit dd8efcb

Browse files
committed
hotfix: undefined portals
1 parent 2c5784e commit dd8efcb

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { block } from 'million/react';
2+
3+
const Svg = block(() => {
4+
return (
5+
<div>
6+
<svg
7+
xmlns="http://www.w3.org/2000/svg"
8+
fill="none"
9+
viewBox="0 0 24 24"
10+
strokeWidth={1.5}
11+
stroke="currentColor"
12+
className="w-6 h-6"
13+
>
14+
<path
15+
strokeLinecap="round"
16+
strokeLinejoin="round"
17+
d="M4.5 12.75l6 6 9-13.5"
18+
/>
19+
</svg>
20+
</div>
21+
);
22+
});
23+
24+
export default Svg;

packages/react/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ export const processProps = (
3737
export const renderReactScope = (
3838
vnode: ReactNode,
3939
unstable: boolean,
40-
portals: MillionPortal[],
40+
portals: MillionPortal[] | undefined,
4141
currentIndex: number,
4242
server: boolean,
4343
) => {
44-
const el = portals[currentIndex]?.current;
44+
const el = portals?.[currentIndex]?.current;
4545
if (typeof window === 'undefined' || (server && !el)) {
4646
return createElement(
4747
RENDER_SCOPE,
@@ -72,7 +72,7 @@ export const renderReactScope = (
7272
portal: reactPortal,
7373
unstable,
7474
};
75-
portals[currentIndex] = millionPortal;
75+
if (portals) portals[currentIndex] = millionPortal;
7676

7777
return millionPortal;
7878
};

0 commit comments

Comments
 (0)