Open this example in the interactive library
Live preview
Source code
// components/TransportBeatDisplay.tsx
import { useState } from "react";
export default function TransportBeatDisplay({ beats = 4 }: { beats?: number } = {}) {
const [i, set] = useState(0);
return (
<button onClick={() => set((n) => (n + 1) % Math.max(1, beats))}>
Advance beat · {i + 1}
</button>
);
}
