Skip to main content

UseSearch

What useSearch returns.

This is an interface exported by @mapcairn/map, checked against version 0.2.0.

Signature​

import type { UseSearch } from "@mapcairn/map";

interface UseSearch

Properties​

clear​

readonly clear: () => void;

Empties the box and cancels everything.

query​

readonly query: string;

The text in the search box.

retry​

readonly retry: () => void;

Runs the current query again at once, for the Retry button.

setQuery​

readonly setQuery: (query: string) => void;

Sets the text as the user typed it. Never searches: it cancels any search in flight and returns to idle, so results for older text never sit under new text.

settle​

readonly settle: (query: string) => void;

Puts text in the box without searching: cancels anything in flight and returns to idle. Used when the user picks a result, so the box shows its label.

state​

readonly state: SearchState;

Where the search stands.

submit​

readonly submit: () => void;

Searches for the current text, for Enter or the Search button. Answers a coordinate pair itself, without the provider. Does nothing when the trimmed text is shorter than MIN_SEARCH_LENGTH, or when the text's own search is already loading or showing its outcome (after a failure it searches again).

See also​

Source: packages/map/src/tools/SearchPill/useSearch.ts:60