Adds Spin button to page

This commit is contained in:
2024-06-09 13:57:09 -04:00
parent 6485396900
commit 8ac072d84b
10 changed files with 39 additions and 12 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ function App() {
<header className="App-header">
<h1>Twitch Chat Randomizer</h1>
<WheelComponent />
</header>
</header>
</div>
);
}
+7 -2
View File
@@ -46,12 +46,12 @@ const WheelComponent = () => {
fetchMessages();
}, []);
useEffect(() => {
const startSpin = () => {
if (data.length > 0) {
setPrizeNumber(Math.floor(Math.random() * data.length));
setMustSpin(true);
}
}, [data]);
};
const handleSpinComplete = () => {
setMustSpin(false);
@@ -73,8 +73,13 @@ const WheelComponent = () => {
mustStartSpinning={mustSpin}
prizeNumber={prizeNumber}
data={data}
spinDuration={.5}
disableInitialAnimation={true}
onStopSpinning={handleSpinComplete}
/>
<button onClick={startSpin} disabled={mustSpin || data.length === 0}>
Start Spin
</button>
</div>
);
};