"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var noop = function noop() {};
var _default = exports["default"] = function _default(defaultGrouping, onChange) {
  if (defaultGrouping === void 0) {
    defaultGrouping = "";
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = (0, _react.useState)(defaultGrouping),
    grouping = _useState[0],
    setGrouping = _useState[1];
  var initialSetRef = (0, _react.useRef)(false);
  (0, _react.useEffect)(function () {
    if (grouping === defaultGrouping) return;
    initialSetRef.current = true;
    setGrouping(defaultGrouping);
  }, [defaultGrouping]);
  var onGroupingChange = (0, _react.useCallback)(function (value) {
    onChange(value);
    setGrouping(value);
  }, [onChange]);
  return [grouping, onGroupingChange];
};