import React, { useState, useMemo } from "react";
import { createContext } from "use-context-selector";
import useContext from "../../utils/useContextSelector";
var TableContext = createContext([]);
export var useTableState = function useTableState(select) {
  return useContext(TableContext, function (s) {
    return select(s.state);
  });
};
export var useTableDispatch = function useTableDispatch() {
  return useContext(TableContext, function (s) {
    return s.setState;
  });
};
var initialState = {};
var TableProvider = function TableProvider(_ref) {
  var children = _ref.children;
  var _useState = useState(initialState),
    state = _useState[0],
    setState = _useState[1];
  var contextValue = useMemo(function () {
    return {
      state: state,
      setState: setState
    };
  }, [state]);
  return /*#__PURE__*/React.createElement(TableContext.Provider, {
    value: contextValue
  }, useMemo(function () {
    return children;
  }, [children]));
};
export default TableProvider;