diff --git a/src/components/Body.tsx b/src/components/Body.tsx index a3c291d..9ddd1a3 100644 --- a/src/components/Body.tsx +++ b/src/components/Body.tsx @@ -1,10 +1,16 @@ // local imports import React from 'react' -import Chart1 from './Chart1' +import ChartDisplay from './ChartDisplay' +import { getChart1Data } from '../static/helpers' +import { type ChartDataType } from '../interfaces/interface' const Body: React.FC = () => { const [chartNum, setChartNum] = React.useState(1) + const [currentChartData, setCurrentChartData] = React.useState( + getChart1Data() + ) + // local functions const updateChart = (e: React.MouseEvent): void => { e.preventDefault() setChartNum((chartNum) => { @@ -12,11 +18,17 @@ const Body: React.FC = () => { else return 1 }) } + + // useEffect hook + React.useEffect(() => { + if (chartNum === 1) setCurrentChartData(getChart1Data()) + else if (chartNum === 2) setCurrentChartData(getChart1Data()) + }, [chartNum]) + + // return statement return (
-
- {chartNum === 1 && } -
+
{}