"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var noop = function noop() {};
var defaultPaginationOptions = {
  pageIndex: 0,
  pageSize: 0
};
var _default = exports["default"] = function _default(paginationOptions, onChange) {
  if (paginationOptions === void 0) {
    paginationOptions = defaultPaginationOptions;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = (0, _react.useState)(function () {
      return paginationOptions;
    }),
    pagination = _useState[0],
    setPagination = _useState[1];
  var initialSetRef = (0, _react.useRef)(false);
  (0, _react.useEffect)(function () {
    if (pagination === paginationOptions) return;
    initialSetRef.current = true;
    setPagination(paginationOptions);
  }, [paginationOptions]);
  var onPaginationChange = (0, _react.useCallback)(function (value) {
    onChange(value);
    setPagination(value);
  }, []);
  return [pagination, onPaginationChange];
};