🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
UI libraries / React InstantSearch / Widgets

useConfigureRelatedItems()

This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.

If you were using React InstantSearch v6, you can upgrade to v7.

If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.

If you want to keep using React InstantSearch v6, you can find the archived documentation.

About this Hook

This Hook doesn’t render anything but computes search parameters to help create a list of related items.

The useConfigureRelatedItems Hook isn’t available in React InstantSearch, but you can make a custom version with useConnector() and connectConfigureRelatedItems.

It’s good practice to put related items in a separate <Index>.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { EXPERIMENTAL_connectConfigureRelatedItems } from 'instantsearch.js/es/connectors';
import { useConnector, useHits } from 'react-instantsearch';

export function useConfigureRelatedItems(props) {
  return useConnector(EXPERIMENTAL_connectConfigureRelatedItems, props);
}

export function ConfigureRelatedItems(props) {
  // You need to pass a stable reference (for example, with `useMemo()`) 
  // if you transform the props before passing them to the Hook.
  useConfigureRelatedItems(props);
  const { hits } = useHits();

  return <>{/* Your JSX */}</>;
}
Did you find this page helpful?