Adds Spin button to page
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ function App() {
|
||||
<header className="App-header">
|
||||
<h1>Twitch Chat Randomizer</h1>
|
||||
<WheelComponent />
|
||||
</header>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user