If you are using the instantsearch.highlight
helper function within your hits connector, you may receive the following warning:
[InstantSearch.js]: `instantsearch.highlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Highlight` component.
As indicated, you can still use the highlight helper function within your connector in InstantSearch.js version 4. The function will not be deprecated until version 5, which does not yet have a release date at the time of writing (Aug. 2, 2024).
To proactively implement this functionality in a way that will both avoid the console warning and prepare for compatibility with version 5, you can use getPropertyByPath
and getHighlightedParts
utility functions from InstantSearch.js, then render however you want inside the connector.
Below is an example and a link to the corresponding Github repos.
Example:
Github Repos:
- https://github.com/algolia/instantsearch/blob/master/packages/instantsearch.js/src/lib/utils/getHighlightedParts.ts
- https://github.com/algolia/instantsearch/blob/master/packages/instantsearch.js/src/lib/utils/getPropertyByPath.ts