Skip to content

feat(react-instantsearch-core): provide facet metadata to DynamicWidgets fallback#6929

Closed
Haroenv wants to merge 1 commit intomasterfrom
feat/dynamic-widgets-fallback-facet-metadata
Closed

feat(react-instantsearch-core): provide facet metadata to DynamicWidgets fallback#6929
Haroenv wants to merge 1 commit intomasterfrom
feat/dynamic-widgets-fallback-facet-metadata

Conversation

@Haroenv
Copy link
Copy Markdown
Contributor

@Haroenv Haroenv commented Mar 17, 2026

Summary

This change enriches DynamicWidgets fallback rendering with facet metadata from the current results, so fallback components can make visibility decisions without mounting additional facet connectors.

What changed

  • DynamicWidgets now passes extra props to fallbackComponent:
    • canRefine: boolean
    • facetValues: Record<string, number>
  • The original attribute prop remains unchanged.
  • Facet metadata is sourced from _rawResults[0].facets when available, with fallback to results.facets.

Why

When many dynamic facets are rendered through fallbackComponent, apps often mount useRefinementList() / useHierarchicalMenu() just to know whether a facet has values. This creates duplicate connector registrations and can significantly increase initial rendering cost for high facet counts.

By passing facet metadata directly from DynamicWidgets, fallback components can skip those extra connectors and stay mostly presentational.

Tests

Added test coverage in:

  • packages/react-instantsearch-core/src/components/__tests__/DynamicWidgets.test.tsx

New test validates that fallbackComponent receives:

  • attribute
  • canRefine
  • facetValues

Validation run

  • yarn jest packages/react-instantsearch-core/src/components/__tests__/DynamicWidgets.test.tsx --runInBand
  • yarn jest packages/react-instantsearch-core/src/connectors/__tests__/useDynamicWidgets.test.tsx --runInBand

Notes

This is an incremental, backwards-compatible step toward reducing DynamicWidgets overhead in high-facet scenarios, without removing or changing singular connectors.

@Haroenv
Copy link
Copy Markdown
Contributor Author

Haroenv commented Mar 17, 2026

better version in #6930

@Haroenv Haroenv closed this Mar 17, 2026
@Haroenv Haroenv deleted the feat/dynamic-widgets-fallback-facet-metadata branch March 17, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant