ntcore-ts / @ntcore-ts/react / usePrefixTopic
Function: usePrefixTopic()
usePrefixTopic(
prefix,subscribeOptions?):PrefixTopicUpdate|null
Defined in: react/src/lib/use-prefix-topic.ts:61
Subscribes to all topics under a NetworkTables prefix and returns only the latest update. Each new update replaces the previous one in state; rapid updates result in only the most recent being visible. Use for "react to any change under prefix" or "show last activity." For a full map of all topics under a prefix (e.g. to list or iterate), use usePrefixTopicMap instead.
Unsubscribes on unmount. Prefix topics are subscribe-only.
Parameters
prefix
string
Topic prefix (e.g. "/SmartDashboard" or "/" for all).
subscribeOptions?
Omit<SubscribeOptions, "prefix">
Optional subscribe options (e.g. { periodic: 0.02 }).
Returns
PrefixTopicUpdate | null
Latest update { name, value, type } or null before first update.