import React, { useRef, useEffect } from "react";
import { connect } from "redux-bundler-react";

export default connect(
  "doScalebarInit",
  "selectMap",
  ({ doScalebarInit, map }) => {
    const el = useRef();

    useEffect(() => {
      if (!el.current || !map) return undefined;
      doScalebarInit(el.current);
    }, [el.current, map]);

    return <span ref={el}></span>;
  }
);
