Fix hooks lints

This commit is contained in:
jahooma 2021-12-09 15:03:55 -06:00
parent b5145305e6
commit 02eef10816

View File

@ -9,7 +9,6 @@ import {
Tooltip, Tooltip,
Legend, Legend,
} from 'chart.js' } from 'chart.js'
import { ChartData } from 'chart.js'
import { Line } from 'react-chartjs-2' import { Line } from 'react-chartjs-2'
import { bids as sampleBids } from '../../lib/simulator/sample-bids' import { bids as sampleBids } from '../../lib/simulator/sample-bids'
import { Entry, makeEntries } from '../../lib/simulator/entries' import { Entry, makeEntries } from '../../lib/simulator/entries'
@ -146,15 +145,14 @@ function NewBidTable(props: {
setNewBidType(newBidType === 'YES' ? 'NO' : 'YES') setNewBidType(newBidType === 'YES' ? 'NO' : 'YES')
} }
const nextEntry = useMemo(() => { let nextEntry: Entry | null = null
if (newBid) {
const nextBid = makeBid(newBidType, newBid) if (newBid) {
const fakeBids = [...bids.slice(0, steps), nextBid] const nextBid = makeBid(newBidType, newBid)
const entries = makeEntries(fakeBids) const fakeBids = [...bids.slice(0, steps), nextBid]
return entries[entries.length - 1] const entries = makeEntries(fakeBids)
} nextEntry = entries[entries.length - 1]
return null }
}, [newBid, newBidType, steps])
return ( return (
<table className="table table-compact my-8 w-full"> <table className="table table-compact my-8 w-full">
@ -236,21 +234,16 @@ export default function Simulator() {
) )
const probs = entries.map((entry) => entry.prob) const probs = entries.map((entry) => entry.prob)
// Set up chart const chartData = {
const [chartData, setChartData] = useState({ datasets: [] } as ChartData) labels: Array.from({ length: steps }, (_, i) => i + 1),
datasets: [
useEffect(() => { {
setChartData({ label: 'Implied probability',
labels: Array.from({ length: steps }, (_, i) => i + 1), data: probs,
datasets: [ borderColor: 'rgb(75, 192, 192)',
{ },
label: 'Implied probability', ],
data: probs, }
borderColor: 'rgb(75, 192, 192)',
},
],
})
}, [steps])
return ( return (
<div className="overflow-x-auto px-12 mt-8 text-center"> <div className="overflow-x-auto px-12 mt-8 text-center">
@ -299,7 +292,7 @@ export default function Simulator() {
Probability of Probability of
<div className="badge badge-success text-2xl h-8 w-18">YES</div> <div className="badge badge-success text-2xl h-8 w-18">YES</div>
</h1> </h1>
<Line data={chartData as any} height={200} /> <Line data={chartData} height={200} />
</div> </div>
</div> </div>
</div> </div>