import { useRef } from "react";
import identity from "lodash/identity";
import isEqual from "lodash/isEqual";
import { useContextSelector } from "use-context-selector";
export default (function (Context, select) {
  if (select === void 0) {
    select = identity;
  }
  var prevRef = useRef();
  return useContextSelector(Context, function (state) {
    var selected = select(state);
    if (!isEqual(prevRef.current, selected)) prevRef.current = selected;
    return prevRef.current;
  });
});