scichart-react
Version:
React wrapper for SciChart JS
32 lines • 1.99 kB
JavaScript
"use client";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SciChartMemoryDebugWrapper = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const scichart_1 = require("scichart");
/**
* SciChartMemoryDebugWrapper is used to help checking memory leaks related to SciChart.
* Rendering the component enables Memory Debug Mode and adds extra UI elements to allow easily mount/unmount the child components
* @remarks Find more info at [Memory Leak Debugging docs](https://www.scichart.com/documentation/js/current/MemoryLeakDebugging.html)
*/
function SciChartMemoryDebugWrapper(props) {
(0, react_1.useState)(() => {
scichart_1.MemoryUsageHelper.isMemoryUsageDebugEnabled = true;
scichart_1.SciChartSurface.autoDisposeWasmContext = true;
scichart_1.SciChartSurface.wasmContextDisposeTimeout = 0;
});
const [drawChart, setDrawChart] = (0, react_1.useState)(false);
const handleCheckbox = e => {
setDrawChart(e.target.checked);
};
const handleClick = () => {
// @ts-ignore force garbage collection in Chrome if enabled with --js-flags="--expose-gc"
window.gc && window.gc();
const state = scichart_1.MemoryUsageHelper.objectRegistry.getState();
console.log("state", state);
};
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { style: { position: "fixed", top: 0, left: 0 }, children: [(0, jsx_runtime_1.jsx)("input", { type: "checkbox", checked: drawChart, onChange: handleCheckbox }), " Render Child Components Tree", (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("input", { type: "button", onClick: handleClick, value: "Log Object Registry State" }), (0, jsx_runtime_1.jsx)("br", {}), drawChart ? props.children : null] }) }));
}
exports.SciChartMemoryDebugWrapper = SciChartMemoryDebugWrapper;
//# sourceMappingURL=SciChartMemoryDebugWrapper.js.map
;