From fab691443f0caec2a658744da183fb4a3f046546 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Thu, 9 Dec 2021 16:44:20 -0600 Subject: [PATCH] Fix hooks lints (#3) --- web/pages/simulator/index.tsx | 45 +++++++++++++++-------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/web/pages/simulator/index.tsx b/web/pages/simulator/index.tsx index a73d96a1..5f57f49d 100644 --- a/web/pages/simulator/index.tsx +++ b/web/pages/simulator/index.tsx @@ -9,7 +9,6 @@ import { Tooltip, Legend, } from 'chart.js' -import { ChartData } from 'chart.js' import { Line } from 'react-chartjs-2' import { bids as sampleBids } from '../../lib/simulator/sample-bids' import { Entry, makeEntries } from '../../lib/simulator/entries' @@ -147,15 +146,14 @@ function NewBidTable(props: { setNewBidType(newBidType === 'YES' ? 'NO' : 'YES') } - const nextEntry = useMemo(() => { - if (newBid) { - const nextBid = makeBid(newBidType, newBid) - const fakeBids = [...bids.slice(0, steps), nextBid] - const entries = makeEntries(fakeBids) - return entries[entries.length - 1] - } - return null - }, [newBid, newBidType, steps]) + let nextEntry: Entry | null = null + + if (newBid) { + const nextBid = makeBid(newBidType, newBid) + const fakeBids = [...bids.slice(0, steps), nextBid] + const entries = makeEntries(fakeBids) + nextEntry = entries[entries.length - 1] + } return ( @@ -239,21 +237,16 @@ export default function Simulator() { ) const probs = entries.map((entry) => entry.prob) - // Set up chart - const [chartData, setChartData] = useState({ datasets: [] } as ChartData) - - useEffect(() => { - setChartData({ - labels: Array.from({ length: steps }, (_, i) => i + 1), - datasets: [ - { - label: 'Implied probability', - data: probs, - borderColor: 'rgb(75, 192, 192)', - }, - ], - }) - }, [steps]) + const chartData = { + labels: Array.from({ length: steps }, (_, i) => i + 1), + datasets: [ + { + label: 'Implied probability', + data: probs, + borderColor: 'rgb(75, 192, 192)', + }, + ], + } return (
@@ -303,7 +296,7 @@ export default function Simulator() { Probability of
YES
- +