Skip to content

[Next.js] How to change index (for localization)? #5629

Closed Answered by dhayab
JanKups asked this question in Q&A
Discussion options

You must be logged in to vote

You should be able to force a remount of <InstantSearch> by setting its key prop to your index name state getter.

function Page() {
  const [indexName, setIndexName] = useState('...');
  
  /* ... */
  
  return (
    <InstantSearch searchClient={searchClient} indexName={indexName} key={indexName}>
      {/* ... */}
    </InstantSearch>
  );
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@JanKups
Comment options

@JanKups
Comment options

Answer selected by JanKups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Library: React InstantSearch ≥ 7 Issues in any of the react-instantsearch@7 packages (formerly named react-instantsearch-hooks)
2 participants