/*
 * @Author: codingfly
 * @Description:
 * @Date: 2022-02-21 08:08:15
 * @LastEditTime: 2022-02-23 08:35:32
 * @FilePath: \remaxui\src\down-time\index.tsx
 */
import { getDownCount } from 'parsec-hooks/lib/downTimeHooks';
import Native from '../native';
import React, { useEffect, useRef } from 'react';
export default (function (_ref) {
  var targetDate = _ref.targetDate,
      format = _ref.format,
      style = _ref.style,
      className = _ref.className;
  var ref = useRef(null);
  useEffect(function () {
    if (!targetDate) return;

    var fn = function fn() {
      var _ref$current;

      return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.setData({
        content: format(getDownCount(targetDate))
      });
    };

    fn();
    var timer = setInterval(fn, 1000);
    return function () {
      return clearInterval(timer);
    };
  }, [format, targetDate]);
  return /*#__PURE__*/React.createElement(Native, {
    ref: ref,
    initData: {
      style: style,
      className: className
    }
  });
});