import { useRecoilValue } from 'recoil';
import get from 'lodash/get';
import useRegisterTimestamp from '../useRegisterTimestamp';
const useTimestampedData = function useTimestampedData(atom, opts = {}) {
  const {
    register = true
  } = opts;
  const data = useRecoilValue(atom);
  const timestamp = get(data, 'metadata.lastUpdated', undefined);
  useRegisterTimestamp(register ? timestamp : undefined);
  return get(data, 'data', undefined);
};
export default useTimestampedData;