I can’t figure out how to create bindings for a couple Algolia connectors, which are higher order components.
For example there’s the connectStateResults which let’s you access the search state.
I’ve used this in typescript like so:
import { StateResultsProvided } from "react-instantsearch-core"
import { connectStateResults } from "react-instantsearch-dom"
interface Props extends StateResultsProvided {
expectedNumberOfHits: number
}
const StateResults: React.FC<Props> = ({
children,
searching,
isSearchStalled,
searchState,
searchResults,
expectedNumberOfHits,
}) => {
...content omitted
}
export const AlgoliaLoadingWrapper = connectStateResults(StateResults)
How do I achieve something similar in ReScript where I have my own component which takes a prop, in this case expectedNumberOfHits
, and that gets added to the props from StateResultsProvived
.
I’ve tried a few different approached without luck. My current iteration looks like this:
@module("react-instantsearch-dom")
external connectStateResults: React.element => React.element = "connectStateResults"
type refinementList = {key: array<string>}
type searchState = {query: option<string>, refinementList: option<Js.Dict.t<string>>}
type searchResults = {hits: option<array<Algolia.provision>>}
@react.component
let make = (
~children,
~expectedNumberOfHits,
~searching,
~isSearchStalled,
~searchState,
~searchResults,
) =>
{
...content omitted
}->connectStateResults
The main problem is understanding how I can create a component where I provide children
and expectedNumberOfHits
my self, but still have access to the other props provided by the wrapper connectStateResults