Files
ETB/ETB-FrontEnd/node_modules/@mui/x-data-grid/hooks/utils/useGridSelector.js
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

20 lines
617 B
JavaScript

import { buildWarning } from '../../utils/warning';
function isOutputSelector(selector) {
return selector.acceptsApiRef;
}
const stateNotInitializedWarning = buildWarning(['MUI: `useGridSelector` has been called before the initialization of the state.', 'This hook can only be used inside the context of the grid.']);
export const useGridSelector = (apiRef, selector) => {
if (process.env.NODE_ENV !== 'production') {
if (!apiRef.current.state) {
stateNotInitializedWarning();
}
}
if (isOutputSelector(selector)) {
return selector(apiRef);
}
return selector(apiRef.current.state);
};