Mr. Doge
Hooks

useOddsMovement

Diffs each line's price against its previous snapshot, so an Odds Selector can color a price green or red as live odds change.

Movement isn't something the SDK computes or sends. odds.subscribe pushes a full replace-in-place snapshot on every change (see useOdds), with no "this went up" flag attached. This hook remembers the previous snapshot's prices itself and diffs against the new one, entirely client-side.

Installation

pnpm dlx shadcn@latest add https://mrdoge.co/r/use-odds-movement.json

Pairs with useOdds; pass it the same market. No extra SDK setup beyond what useOdds already needs.

Usage

import { useOddsMovement } from "@/hooks/use-odds-movement"

const movementById = useOddsMovement(market)

Parameters

Prop

Type

Returns

Record<string, "up" | "down" | "flat">, keyed by line id. In practice only "up" and "down" are ever produced; "flat" exists on the type (OddsMovement, from @mrdoge/react, structurally the same type Odds Selector's own movement prop takes) but this hook never emits it. A line only gets an entry once there's a previous price to compare against. The first snapshot ever seen for a given id has nothing to diff, and an unchanged price isn't given an entry either. A color that never goes away would just be noise; ids missing from the result should render with the default price color.

On this page