import { useState, useEffect } from "react";
import withHelperText from "../../../hoc/withHelperText";
import withLabel from "../../../hoc/withLabel";
import ChartWidget, { ChartProps } from "./ChartWidget";

const ChartContainer = (props: ChartProps) => {
  const [chartProps, setChartProps] = useState<ChartProps>({} as ChartProps);
  
  useEffect(() => {
    setChartProps({ ...props });
  }, [props]);
  
  return <ChartWidget {...chartProps} />;
};

export default withHelperText(withLabel(ChartContainer));
