#community-help

Refreshing `react-instantsearch` Component Dynamically.

TLDR robert asked how to trigger a refresh of react-instantsearch to display dynamic uploads. Jason suggested using the refresh prop.

Powered by Struct AI
2
18mo
Solved
Join the chat
Jul 13, 2022 (18 months ago)
robert
Photo of md5-0ca37054c6c9042aa04fcfb92cc7d99c
robert
08:06 PM
does anybody know how to trigger a refresh of the react-instantsearch ? my use case is i'm adding documents dynamically via an upload & i want the component to show the latest. I know it isn't exactly a typesense issue but figured I'd ask here anyways

const CustomHits = connectHits(Hits);
const SearchBox = connectSearchBox(Box);

export const Search = ({ onSelect = null }: { onSelect: any }) => {
  const { organization } = useActiveOrganization();

  return (
    <InstantSearch
      indexName="files"
      searchClient={typesenseInstantSearchAdapter.searchClient}
    >
      <Configure filters={`org_id:${organization?.id}`} />
      <div className="sticky top-0 bg-white">
        <SearchBox />
      </div>
      <CustomHits setClickedHit={onSelect} />
    </InstantSearch>
  );
};

I'm using the typesense adapter here.