Skip to main content

SearchResultState

Home > @backstage/plugin-search-react > SearchResultState

Call a child render function passing a search state as an argument.

Signature:

SearchResultState: (props: SearchResultStateProps) => React.JSX.Element

Remarks

By default, results are taken from context, but when a "query" prop is set, results are requested from the search api.

Example 1

Consuming results from context:

<SearchResultState>
{({ loading, error, value }) => (
<List>
{value?.map(({ document }) => (
<DefaultSearchResultListItem
key={document.location}
result={document}
/>
))}
</List>
)}
</SearchResultState>

Example 2

Requesting results using the search api:

<SearchResultState query={{ term: 'documentation' }}>
{({ loading, error, value }) => (
<List>
{value?.map(({ document }) => (
<DefaultSearchResultListItem
key={document.location}
result={document}
/>
))}
</List>
)}
</SearchResultState>