@elastic/eui
Version:
Elastic UI Component Library
37 lines (34 loc) • 1.22 kB
JavaScript
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import React, { createContext, useRef, useContext } from 'react';
import { createEuiTableStore } from './store';
import { jsx as ___EmotionJSX } from "@emotion/react";
var EuiTableStoreContext = /*#__PURE__*/createContext(null);
/**
* @internal
*/
export var EuiTableStoreProvider = function EuiTableStoreProvider(_ref) {
var children = _ref.children;
var store = useRef(null);
if (!store.current) {
store.current = createEuiTableStore();
}
return ___EmotionJSX(EuiTableStoreContext.Provider, {
value: store.current
}, children);
};
/**
* @internal
*/
export var useEuiTableColumnDataStore = function useEuiTableColumnDataStore() {
var store = useContext(EuiTableStoreContext);
if (!store) {
throw new Error('[useEuiTableColumnDataStore] Store context not found. This hook must be used within EuiTable!');
}
return store;
};