From 540f00e624e6841995d3d86bb4e963b4619f2d88 Mon Sep 17 00:00:00 2001 From: Thomas Roest Date: Fri, 19 Jan 2024 11:56:04 +0100 Subject: [PATCH] Fix preview error handling (#2158) fix: fix preview not visible after error fixes https://github.com/styleguidist/react-styleguidist/issues/2154 --------- Co-authored-by: Thomas Roest --- src/client/rsg-components/Preview/Preview.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/rsg-components/Preview/Preview.tsx b/src/client/rsg-components/Preview/Preview.tsx index 3abbf3f10..a2e4a82c3 100644 --- a/src/client/rsg-components/Preview/Preview.tsx +++ b/src/client/rsg-components/Preview/Preview.tsx @@ -93,10 +93,16 @@ export default class Preview extends Component { /> ); + /* istanbul ignore next */ window.requestAnimationFrame(() => { - // this.unmountPreview(); + if (!this.mountNode) { + return; + } try { - if (this.mountNode && this.reactRoot) { + if (this.reactRoot === null) { + this.reactRoot = createRoot(this.mountNode); + this.reactRoot.render(wrappedComponent); + } else { this.reactRoot.render(wrappedComponent); } } catch (err) {