React InstantSearch provides a CurrentRefinements
component which gives the currently selected refinements.
But all I want is to get the number of filters (refinements) being applied. I feel like this should be really easy but have been banging my head for the past 4 hours trying to figure it out.
Edit: You can see a working example with <CurrentRefinements>
here
But again, my goal isn't to list the current refinements, it's to get a count of the number of refinements being applied in total.
I got it working using one of the connectors they provide. Here's the solution:
import React, {Component} from 'react'
import {connectCurrentRefinements} from 'react-instantsearch/connectors'
class RefinementCount extends Component {
render() {
return (
<h1>filtered: {this.props.items.length}</h1>
)
}
}
export default connectCurrentRefinements(RefinementCount)
Relevants docs: https://community.algolia.com/react-instantsearch/connectors/connectCurrentRefinements.html