Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remix useFetcher() cannot be used inside InstantSearch #5932

Open
1 task done
lildesert opened this issue Nov 15, 2023 · 1 comment
Open
1 task done

Remix useFetcher() cannot be used inside InstantSearch #5932

lildesert opened this issue Nov 15, 2023 · 1 comment
Labels
triage Issues to be categorized by the team

Comments

@lildesert
Copy link

lildesert commented Nov 15, 2023

馃悰 Current behavior

Hi,

One of the numerous frustrations I got from trying to use algolia with Remix is that I cannot use useFetcher() in any component that is a child of <InstantSearch>.
The InstantSearch component affects the react-router behavior (which Remix uses under the hood).
On new versions of Remix, the thrown error is the following useFetcher must be used inside a RouteContext. So I guess InstantSearchContext doesn't pair well with Remix RouteContext.

Small edit: it seems related to SSR since an easy workaround is to render the component only client-side with ClientOnly for example.

Thanks for any help on this!

馃攳 Steps to reproduce

Just use Remix useFetcher in any component inside . See sandbox for reproduction.

Live reproduction

https://codesandbox.io/p/sandbox/remix-algolia-usefetcher-h3x9rh

馃挱 Expected behavior

useFetcher() works out of the box and allows me to fetch or post data.

Package version

react-instantsearch 7.2.0, remix 2.2.0, algoliasearch 4.20.0

Operating system

No response

Browser

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lildesert lildesert added the triage Issues to be categorized by the team label Nov 15, 2023
@aymeric-giraudet
Copy link
Member

aymeric-giraudet commented Nov 22, 2023

Hi @lildesert

The problem is the component is not being rendered in the Remix context it needs.

There are 2 ways to circumvent this :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues to be categorized by the team
Projects
None yet
Development

No branches or pull requests

2 participants