From 2261b9915a2539403f93d31eb5ac334aaddfbf2c Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Tue, 24 Dec 2024 13:51:06 +0000 Subject: [PATCH] fix: workaround for ssr issue of react diff-viewer lib --- admin/src/components/ConfigDiff/index.jsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/admin/src/components/ConfigDiff/index.jsx b/admin/src/components/ConfigDiff/index.jsx index daa0787..2599ac9 100644 --- a/admin/src/components/ConfigDiff/index.jsx +++ b/admin/src/components/ConfigDiff/index.jsx @@ -1,7 +1,23 @@ import React from 'react'; -import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued'; +import RDV, { DiffMethod } from 'react-diff-viewer-continued'; import { useIntl } from 'react-intl'; +/** + * An issue with the diff-viewer library causes a difference in the way the library is exported. + * Depending on whether the library is loaded through the browser or through the server, the default export may or may not be present. + * This causes issues with SSR and the way the library is imported. + * + * Below a workaround to fix this issue. + * + * @see https://github.com/Aeolun/react-diff-viewer-continued/issues/43 + */ +let ReactDiffViewer; +if (typeof RDV.default !== 'undefined') { + ReactDiffViewer = RDV.default; +} else { + ReactDiffViewer = RDV; +} + import { Modal, Grid,