"use strict";

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