@nosto/preact

    Function useFacets

    • Preact hook that import facets to the component.

      Returns { facets: SearchFacet[]; loading: boolean }

      import { useFacets } from '@nosto/preact'
      import { defaultConfig } from "../config"

      export default () => {
      const { loading, facets } = useFacets()

      return (
      <div style={loading ? "opacity: 0.3;" : ""}>
      <div>
      <ul>
      {facets.map(facet => {
      switch (facet.type) {
      case "terms":
      return <Facet facet={facet} />
      case "stats":
      return <RangeFacet facet={facet} />
      default:
      return null
      }
      })}
      </ul>
      </div>
      </div>
      )
      }
    MMNEPVFCICPMFPCPTTAAATR