By following this example to create reusable SciChart component in React:
https://www.scichart.com/documentation/js/current/TutorialReusableReactComponent.html
The chart cannot be created when run in dev mode. But it works well under production mode. I think it’s because React renders components twice in strict mode. It seems that SciChart got problems to create chart with the following logic when running the application in dev mode. Is this true? Or I missed anything?
useEffect(() => {
const chartInitializationPromise = props.initChart(rootElementId).then((initResult) => {
sciChartSurfaceRef.current = initResult.sciChartSurface;
return initResult.sciChartSurface;
});
const performCleanup = () => {
sciChartSurfaceRef.current.delete();
sciChartSurfaceRef.current = undefined;
};
return () => {
// check if chart is already initialized or wait init to finish before deleting it
sciChartSurfaceRef.current ? performCleanup() : chartInitializationPromise.then(performCleanup);
};
}, []);
- Quyen Sy asked 1 year ago
- last active 8 months ago