@neo4j-nvl/react 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -67,5 +67,7 @@ declare const BasicNvlWrapper: NamedExoticComponent<{
|
|
|
67
67
|
nvlCallbacks?: ExternalCallbacks;
|
|
68
68
|
/** An object containing options for the NVL instance */
|
|
69
69
|
nvlOptions?: NvlOptions;
|
|
70
|
+
/** A callback to handle any errors that happen during NVL initialization */
|
|
71
|
+
onInitializationError?: (error: unknown) => void;
|
|
70
72
|
}>;
|
|
71
73
|
export { BasicNvlWrapper };
|
|
@@ -56,7 +56,7 @@ import { useDeepCompareEffect } from '../utils/hooks';
|
|
|
56
56
|
* </div>
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions }, ref) => {
|
|
59
|
+
const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, nvlCallbacks = {}, nvlOptions, onInitializationError }, ref) => {
|
|
60
60
|
useImperativeHandle(ref, () => {
|
|
61
61
|
const nvlMethods = Object.getOwnPropertyNames(NVL.prototype);
|
|
62
62
|
return nvlMethods.reduce((current, method) => (Object.assign(Object.assign({}, current), { [method]: (...args) => nvl && nvl[method](...args) })), {});
|
|
@@ -71,12 +71,23 @@ const BasicNvlWrapper = memo(forwardRef(({ nodes, rels, layout, layoutOptions, n
|
|
|
71
71
|
if (layout) {
|
|
72
72
|
combinedOptions.layout = layout;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
let newNvl;
|
|
75
|
+
try {
|
|
76
|
+
newNvl = new NVL(containerRef.current, currentNodes, currentRels, combinedOptions, nvlCallbacks);
|
|
77
|
+
setNvl(newNvl);
|
|
78
|
+
setCurrentRels(rels);
|
|
79
|
+
setCurrentNodes(nodes);
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
if (typeof onInitializationError === 'function') {
|
|
83
|
+
onInitializationError(e);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
78
89
|
return () => {
|
|
79
|
-
newNvl.destroy();
|
|
90
|
+
newNvl === null || newNvl === void 0 ? void 0 : newNvl.destroy();
|
|
80
91
|
};
|
|
81
92
|
}
|
|
82
93
|
}, []);
|