Skip to content

useReactions

function useReactions(
activityId,
initialCounts?,
initialOwn?): object;

Optimistic like/unlike counters. Inside a disabled provider, react/unreact are full no-ops resolving undefined (no optimistic bump either) and enabled is false.

react(kind) / unreact(kind) reject after rolling back — see the file header.

Parameter Type Default value
activityId string undefined
initialCounts Record<string, number> {}
initialOwn string[] []

object

counts: Record<string, number>;
enabled: boolean;
ownReactions: string[];
react: (kind, opts?) => Promise<void>;
Parameter Type
kind string
opts? { onError?: OptimisticOnError; }
opts.onError? OptimisticOnError

Promise<void>

unreact: (kind, opts?) => Promise<void>;
Parameter Type
kind string
opts? { onError?: OptimisticOnError; }
opts.onError? OptimisticOnError

Promise<void>

The network error after the optimistic update has been rolled back.