import _extends from "@babel/runtime/helpers/extends";
import React, { useEffect } from 'react';
import { ElementName, IconType } from '../../../../../constants';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import { BaseBadgeElement, toBadgeProps } from '../common';
const ReactCountElement = props => {
  var _context$reactCount;
  const context = useFlexibleUiContext();
  const data = context ? toBadgeProps((_context$reactCount = context.reactCount) === null || _context$reactCount === void 0 ? void 0 : _context$reactCount.toString()) : null;
  const {
    onRender,
    ...restProps
  } = props || {};
  useEffect(() => {
    onRender === null || onRender === void 0 ? void 0 : onRender(!!data);
  }, [data, onRender]);
  return data ? /*#__PURE__*/React.createElement(BaseBadgeElement, _extends({
    icon: IconType.React
  }, data, restProps, {
    name: ElementName.ReactCount
  })) : null;
};
export default ReactCountElement;