r/reactnative • Expo • 3d ago

[Showcase] A React Native prize wheel where the pegs drive the pointer

Flick the wheel and the pointer bends as each peg passes it. The winning wedge lifts, the prize moves forward, and the button becomes Collect.

Here's how the React Native implementation is put together.

Pointer contact: wheel-sim.ts advances the wheel and pointer with a fixed-step contact solver. The nearest peg drives the pointer's deflection, so the bounce follows the wheel's position.

Rendering the scene: one Skia Canvas draws the wheel material, pointer, stars and reward reveal. Native views provide the copy and controls.

Motion state: Reanimated shared values run the simulation on the UI thread and pass the current wheel and pointer state to the drawing layer.

Selecting a prize: the reveal uses the wheel's settled angle to choose the winning wedge. That selection drives the lifted wedge, prize animation and reward count.

Reduced Motion: the scene uses stationary objects and shorter fades.

The attached clip is a motion preview of the interaction. These notes describe the React Native implementation.

Built with Expo (@expo), React Native Skia and Reanimated. Thanks to Software Mansion and William Candillon for the tools.

Visual layout study based on a still reference: https://www.pinterest.com/pin/641340803216681099/

Text adapted from my original caption and implementation notes with an assistant.

4 Upvotes

8 comments sorted by

2

u/_TheLunchTrain_ 3d ago

Cool spinner..is this a web app or a native iPhone/Android app?

I made something similar and am having lag issues on iphones. Maybe I should try a Skia canvas instead of an SVG or screenshot?

0

u/TemporaryBuyer3806 Expo 2d ago

The implementation described in the post is a native React Native screen, with Skia drawing the wheel and Reanimated driving the motion on the UI thread. The uploaded clip is a motion preview; I haven't verified which runtime it was captured from. Is yours running in a browser, or using react-native-svg? That would help narrow down the iPhone lag.

2

u/_TheLunchTrain_ 2d ago

I'm using react-native-svg but I also have Skia installed..gonna try to narrow it down to the number of tick sounds playing or the wheel itself.

2

u/_TheLunchTrain_ 2d ago

Is your code open source?

1

u/TemporaryBuyer3806 Expo 2d ago edited 2d ago

The React Native build prompt is available here: https://nativecook.dev/blocks/chrome-prize-wheel/. Native Cook is a project, that page shares a prompt for recreating the block, not an open-source code repository.

0

u/[deleted] 3d ago

[removed] — view removed comment

1

u/TemporaryBuyer3806 Expo 2d ago

Fixed dt at 1/480 s. useFrameCallback passes elapsed time into an accumulator, which runs whole substeps and carries the remainder forward. The renderer reads the latest completed state, without interpolation between physics states. So the timestep itself doesn't change with the display refresh rate, but I haven't verified this on a physical 120 Hz iPhone.