Describe the bug 馃悰
I am using connectRange connector to display slider in React Native but it provides min and max value undefined in every render
Output in dev console
{
...otherFields,
min: undefined,
max: undefined,
currentRefinment: {
min: undefined,
max: undefined,
}
}
To Reproduce 馃攳
Due to project begin private i can't share the whole repo:
but here is the main file:
...otherImports
import { Configure, InstantSearch } from "react-instantsearch-native"
import {
connectInfiniteHits,
connectRange,
connectSearchBox,
} from "react-instantsearch/connectors"
import ResultsComponent from './ResultsComponent'
class Products extends Component<Props, {}> {
render() {
return (
<Block flex={1} color="gray3">
<InstantSearch
appId="[APP_ID]"
apiKey="[API_KEY]"
indexName="[INDEX_NAME]"
initialParams={{ filters: "category:jordan" }}
>
<RangeInput attribute="price" />
<Results />
</InstantSearch>
</Block>
)
}
}
const RangeInput = connectRange(props => {
console.log(props)
return <Text>I am from Range!</Text>
})
const Results = connectInfiniteHits(ResultsComponent)
export default Products
Expected behavior 馃挱
Expected to see
Either
{
...otherFields,
min: 1000, // or min value according to filter query
max: 5000, // or max value according to filter query
currentRefinment: {
min: undefined,
max: undefined,
}
}
Or
{
...otherFields,
min: undefined,
max: undefined,
currentRefinment: {
min: 5000, // or min value according to filter query
max: 1000, // or max value according to filter query
}
}
Screenshots 馃枼

Environment:
react-instasearch 5.7.0Additional context
I tried using componentWillReceiveProps but not working
componentWillReceiveProps(nextProps) {
if (nextProps.canRefine) {
this.setState({
min: nextProps.currentRefinement.min,
max: nextProps.currentRefinement.max,
})
}
}
Hi @developerk786, is the attribute price you're using set up as an attributeForFaceting in the index settings (dashboard)?
Thanks, @Haroenv mate i totally forgot about that, now its working as expected!
This is a good reminder for us to give errors or warning messages when incompatible settings are set.