Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(ssr): clearer error message when using ssr without the component (#…
Browse files Browse the repository at this point in the history
…698)

fixes #697

We are patching the InstantSearch instance in SSR, but you could be using the code for SSR without using the patched InstantSearch instance.

The error being thrown then is confusing, since it just complains about a missing property.

We have no differential error management with short & long error messages in prod/dev here yet, so I tried to be between both (not too long)
  • Loading branch information
Haroenv authored Jul 22, 2019
1 parent f4f00a0 commit 20c2153
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/mixins/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const createWidgetMixin = ({ connector } = {}) => ({

const { hydrated, started } = this.instantSearchInstance;
if ((!started && hydrated) || this.$isServer) {
if (typeof this.instantSearchInstance.__forceRender !== 'function') {
throw new Error(
'You are using server side rendering with <ais-instant-search> instead of <ais-instant-search-server>.'
);
}
this.instantSearchInstance.__forceRender(this.widget);
}
} else if (connector !== true) {
Expand Down

0 comments on commit 20c2153

Please sign in to comment.