import { useMemo, useRef } from 'react';
import { isString } from '@pisell/utils';
import useDataSource from "../../dataSourceComponents/hooks/useDataSource";
var useDataSourceKey = function useDataSourceKey() {
  var _useDataSource = useDataSource(),
    dataSource = _useDataSource.dataSource;
  var dataSourceKey = useMemo(function () {
    return isString(dataSource) ? dataSource : (dataSource === null || dataSource === void 0 ? void 0 : dataSource.key) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.tableName);
  }, [dataSource]);
  var dataSourceKeyRef = useRef(dataSourceKey);
  dataSourceKeyRef.current = dataSourceKey;
  return {
    dataSourceKey: dataSourceKey,
    dataSourceKeyRef: dataSourceKeyRef
  };
};
export default useDataSourceKey;