Skip to content

Commit 66602a8

Browse files
mabaasitmcasimir
andauthored
fix(document-view): isRoot fix COMPASS-5872 (#3153)
Co-authored-by: Maurizio Casimirri <[email protected]>
1 parent 2996495 commit 66602a8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/compass-crud/src/components/document.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const Document = (props) => {
1414
} = props;
1515

1616
const doc = useMemo(() => {
17-
if (_doc?.isRoot?.()) {
17+
// COMPASS-5872 If _doc is a plain js object rather than an instance of hadron-document Document
18+
// it may have an isRoot prop, which would cause the isRoot() to throw an error.
19+
if (typeof _doc?.isRoot === 'function' && _doc?.isRoot()) {
1820
return _doc;
1921
}
2022
return new HadronDocument(_doc);

0 commit comments

Comments
 (0)