Skip to content

Commit 0afd02b

Browse files
committed
[test] Fix Dev Overlay Storybook
1 parent ee94be9 commit 0afd02b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
import type { Preview } from '@storybook/react'
2+
import { useInsertionEffect } from 'react'
3+
4+
function CreatePortalNode() {
5+
useInsertionEffect(() => {
6+
const portalNode = document.createElement('nextjs-portal')
7+
document.body.appendChild(portalNode)
8+
9+
return () => {
10+
document.body.removeChild(portalNode)
11+
}
12+
})
13+
14+
return null
15+
}
216

317
const preview: Preview = {
418
parameters: {
@@ -28,6 +42,14 @@ const preview: Preview = {
2842
manual: true,
2943
},
3044
},
45+
decorators: [
46+
(Story) => (
47+
<>
48+
<CreatePortalNode />
49+
<Story />
50+
</>
51+
),
52+
],
3153
}
3254

3355
export default preview

0 commit comments

Comments
 (0)