Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions ROULETTE_BUGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Roulette Bugs

Below is a list of issues discovered in the current codebase along with suggested fixes.

## 1. Repeated event listeners in `SpinResult`
`SpinResult.js` registers a listener to the `ExecutedWager` event inside a `useEffect` whose dependency array includes state values. Each render attaches a new listener without removal, leading to duplicate callbacks.

**Suggestion:** Wrap the subscription in a `useEffect` with an empty dependency array and return a cleanup function that removes the listener.

## 2. Event listener outside `useEffect` in `MostRecentSpinResults`
`MostRecentSpinResults.js` calls `rouletteContractEvents.on` directly inside the component body, meaning a new listener is added on every render.

**Suggestion:** Move the registration into `useEffect` with a cleanup to remove the listener on unmount.

## 3. Inefficient `useEffect` dependencies causing loops
`NumbersHitTracker.js` and `CompletionsCounter.js` both include their own state variables in the `useEffect` dependency arrays while updating those same states. This schedules a new fetch every time the data updates, causing unnecessary loops.

**Suggestion:** Remove the state variables from the dependency arrays and only depend on the player address.

## 4. Stale state in `SpinButton`
`SpinButton.js` sets `shouldDisplayExtraMessage` inside a `useEffect` that also uses the value to set `zIndex` and `color`. Because the previous state is used, the rendered values may be one step behind.

**Suggestion:** Compute a local variable for the desired flag and use it for all state updates inside the effect.

## 5. Incorrect `<br />` tags
`HouseInfo.js` and `PlayerInfo.js` contain `< br />` with a leading space, producing invalid JSX.

**Suggestion:** Replace `< br />` with `<br />`.

## 6. Duplicate value in `NumberHitGameCounter`
`NumberHitGameCounter.js` has `220` listed twice in the outline breakpoints array which appears to be accidental.

**Suggestion:** Remove the duplicate entry so the array progresses as intended.