"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var _identity = _interopRequireDefault(require("lodash/identity"));
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
var _useContextSelector = require("use-context-selector");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var _default = exports["default"] = function _default(Context, select) {
  if (select === void 0) {
    select = _identity["default"];
  }
  var prevRef = (0, _react.useRef)();
  return (0, _useContextSelector.useContextSelector)(Context, function (state) {
    var selected = select(state);
    if (!(0, _isEqual["default"])(prevRef.current, selected)) prevRef.current = selected;
    return prevRef.current;
  });
};