import dynamic from "next/dynamic"; import React, { useMemo, useState } from "react"; import { QuestionWithHistoryFragment } from "../../../fragments.generated"; import { Props as InnerChartProps } from "./InnerChart"; // hopefully doesn't import code, just types - need to check import { InnerChartPlaceholder } from "./InnerChartPlaceholder"; import { Legend } from "./Legend"; import { buildChartData, chartColors } from "./utils"; const InnerChart = dynamic( () => import("./InnerChart").then((mod) => mod.InnerChart), { ssr: false, loading: () => } ); interface Props { question: QuestionWithHistoryFragment; } export const HistoryChart: React.FC = ({ question }) => { // maybe use context instead? const [highlight, setHighlight] = useState(undefined); const data = useMemo(() => buildChartData(question), [question]); return (
({ name, color: chartColors[i], }))} setHighlight={setHighlight} />
); };