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