Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

631 B
Raw Blame
import { useEffect } from 'react'
import { useHelpStore } from '../store/helpStore'

/**
 * Tell the help center which screen is showing. Call it from the screen's data
 * hook, or render `<HelpAnchor id>` from a page body; either way the context
 * is set while the screen is mounted and cleared when it goes away, unless
 * another screen has already taken over.
 */
export function useHelpContext(id: string): void {
  const setContext = useHelpStore(s => s.setContext)
  useEffect(() => {
    setContext(id)
    return () => {
      if (useHelpStore.getState().contextId === id) setContext(null)
    }
  }, [id, setContext])
}