We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2a53705 commit 64d2ca5Copy full SHA for 64d2ca5
src/StickPortal.js
@@ -101,7 +101,7 @@ function StickPortal(
101
{children}
102
103
{top != null && left != null && (
104
- <PortalContext.Provider value={host.parentNode}>
+ <PortalContext.Provider value={host.parentNode || defaultRoot}>
105
{createPortal(
106
<div
107
ref={containerRef}
@@ -122,7 +122,11 @@ function StickPortal(
122
)
123
}
124
125
-export const PortalContext = createContext<?Node>(document.body)
+invariant(document.body, 'Stick can only be used in a browser environment.')
126
+
127
+const defaultRoot = document.body
128
129
+export const PortalContext = createContext<Node>(defaultRoot)
130
131
export default forwardRef<StickPortalPropsT, ?HTMLElement>(StickPortal)
132
0 commit comments