React-instantsearch: Always trigger search when mounting

Created on 25 Sep 2017  Â·  5Comments  Â·  Source: algolia/react-instantsearch

If having a Configure element, react-instantsearch will trigger a request when mouting, depsite we don't do any thing with search feature yet.

<InstantSearch appId={appId} apiKey={apiKey} indexName={indexName}>
    <Configure {...configureAlgolia()} />
  </InstantSearch>

Do you want to request a feature or report a bug?
Bug

Bug: What is the current behavior?
A redundant request
screen shot 2017-09-26 at 12 08 18 am

Bug: What is the expected behavior?
Should not have

Bug: What browsers are impacted? Which versions?
Chrome 60

What is the version you are using? Always use the latest one before opening a bug issue.
4.1.1

♨ API

Most helpful comment

Hi @vinhlh,

As for now there's no API to disable the first query but that's something on the RIS backlog to consider.

I'd prefer to go for this kind of API than coding a particular use-case. (ie: when only Configure type widget, do not search). But let's discuss about it!

All 5 comments

Hi @vinhlh,

As for now there's no API to disable the first query but that's something on the RIS backlog to consider.

I'd prefer to go for this kind of API than coding a particular use-case. (ie: when only Configure type widget, do not search). But let's discuss about it!

@mthuret Also came here to report the same issue. Is there a way to disable that extra search query (unless it is needed by the widget)? Or is that the API you were thinking of adding?

FWIW, apart from extra operation, it makes debugging initially confusing and complicates logic. One can't rely on hits being empty when there is no search query (when using withAutoComplete).

@oyeanuj, in most search UIs you'll want the first launch to have the results for an empty query, which can be used for browsing. In autocomplete cases you can show or hide the results based on how long the query is.

The API Marie was thinking of was indeed something to prevent a search request from firing on a condition that you decide.

In practice this one extra request shouldn't affect you too much, since in the worst case, it'll simply warm up your DNS cache for the real requests

@Haroenv Got it, thanks for the context.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

afgoulart picture afgoulart  Â·  4Comments

markmiller21 picture markmiller21  Â·  3Comments

mxmzb picture mxmzb  Â·  4Comments

flouc001 picture flouc001  Â·  4Comments

denkristoffer picture denkristoffer  Â·  4Comments