UNPKG

@mui/x-data-grid

Version:

The Community plan edition of the MUI X Data Grid components.

17 lines 599 B
const publicApiRefCache = new WeakMap(); export function getPublicApiRef(apiRef) { const privateApi = apiRef.current; let publicApiRef = publicApiRefCache.get(privateApi); if (!publicApiRef) { // The ref is cached per grid instance and getter-based so that `publishEvent` // (called for every grid event) doesn't allocate, and so that consumers cannot // re-point the grid's internal ref through it. publicApiRef = { get current() { return privateApi.getPublicApi(); } }; publicApiRefCache.set(privateApi, publicApiRef); } return publicApiRef; }