Skip to content

Commit acbfdbb

Browse files
authored
Merge pull request #165 from pluginpal/feature/fix-diff-viewer
fix: workaround for ssr issue of react diff-viewer lib
2 parents dbed0cb + 2261b99 commit acbfdbb

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

admin/src/components/ConfigDiff/index.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
import React from 'react';
2-
import ReactDiffViewer, { DiffMethod } from 'react-diff-viewer-continued';
2+
import RDV, { DiffMethod } from 'react-diff-viewer-continued';
33
import { useIntl } from 'react-intl';
44

5+
/**
6+
* An issue with the diff-viewer library causes a difference in the way the library is exported.
7+
* Depending on whether the library is loaded through the browser or through the server, the default export may or may not be present.
8+
* This causes issues with SSR and the way the library is imported.
9+
*
10+
* Below a workaround to fix this issue.
11+
*
12+
* @see https://github.com/Aeolun/react-diff-viewer-continued/issues/43
13+
*/
14+
let ReactDiffViewer;
15+
if (typeof RDV.default !== 'undefined') {
16+
ReactDiffViewer = RDV.default;
17+
} else {
18+
ReactDiffViewer = RDV;
19+
}
20+
521
import {
622
Modal,
723
Grid,

0 commit comments

Comments
 (0)