feat(react): add warning when styles not loaded #4047

This commit is contained in:
moklick
2024-05-07 18:25:04 +02:00
parent 32bac3e133
commit a364a93082
3 changed files with 27 additions and 1 deletions
@@ -0,0 +1,23 @@
import { useEffect, useRef } from 'react';
import { errorMessages } from '@xyflow/system';
import { useStoreApi } from '../../hooks/useStore';
export function useStylesLoadedWarning() {
const store = useStoreApi();
const checked = useRef(false);
useEffect(() => {
if (process.env.NODE_ENV === 'development') {
if (!checked.current) {
const pane = document.querySelector('.react-flow__pane');
if (pane && !(window.getComputedStyle(pane).zIndex === '1')) {
store.getState().onError?.('013', errorMessages['error013']('react'));
}
checked.current = true;
}
}
}, []);
}