Skip to content

Commit 1f5b564

Browse files
committed
Add error handling to hydrate function
1 parent bf2a1f0 commit 1f5b564

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: src/server/pure.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ function createServerRenderer<TProps, TResult>(
2929
if (container) {
3030
throw new Error('The component can only be hydrated once')
3131
} else {
32-
container = document.createElement('div')
33-
container.innerHTML = serverOutput
34-
act(() => {
35-
ReactDOM.hydrate(testHarness(renderProps), container!)
36-
})
32+
if (typeof document !== 'undefined') {
33+
container = document.createElement('div')
34+
container.innerHTML = serverOutput
35+
act(() => {
36+
ReactDOM.hydrate(testHarness(renderProps), container!)
37+
})
38+
}
3739
}
3840
},
3941
rerender(props?: TProps) {

0 commit comments

Comments
 (0)