Issue with integrating vue-instantsearch in my VueJS 3.0 application

In my VueJS 3.0 project using the Options API, I have integrated Firebase and Algolia successfully. While I am able to search multiple indices in Algolia using custom Vue code, I would prefer to utilize vue-instantsearch from Algolia. However, despite my attempts to set up basic search functionality for one index (companyIndex), I am encountering an error that includes my keys:

[Vue warn]: Unhandled error during execution of created hook 
  at <AisSearchBox> 
  at <AisInstantSearch search-client= {transporter: {…}, appId: '#########', addAlgoliaAgent: ƒ, clearCache: ƒ, search: ƒ, …}addAlgoliaAgent: ƒ (e,t)appId: "#########"clearCache: ƒ ()initIndex: ƒ (t)multipleQueries: ƒ (t,n)multipleSearchForFacetValues: ƒ (t,o)search: ƒ (t,n)searchForFacetValues: ƒ (t,o)transporter: {hostsCache: {…}, logger: {…}, requester: {…}, requestsCache: {…}, responsesCache: {…}, …}[[Prototype]]: Object index-name="companyIndex" > 
  at <Home onAuthenticated=fn<setAuthenticatedUser> onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > > 
  at <RouterView onAuthenticated=fn<setAuthenticatedUser> > 
  at <App>
...
runtime-core.esm-bundler.js?5c40:38 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next 
  at <AisSearchBox> 
  at <AisInstantSearch search-client= {transporter: {…}, appId: '#########', addAlgoliaAgent: ƒ, clearCache: ƒ, search: ƒ, …} index-name="companyIndex" > 
  at <Home onAuthenticated=fn<setAuthenticatedUser> onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > > 
  at <RouterView onAuthenticated=fn<setAuthenticatedUser> > 
  at <App>
...
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'instantSearchInstance')
    at Proxy.eval (widget.js?c00b:1)
    at Proxy.created (widget.js?c00b:1)
    at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:154)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js?5c40:163)
    at callHook (runtime-core.esm-bundler.js?5c40:3177)
    at applyOptions (runtime-core.esm-bundler.js?5c40:3107)
    at finishComponentSetup (runtime-core.esm-bundler.js?5c40:7218)
    at setupStatefulComponent (runtime-core.esm-bundler.js?5c40:7143)
    at setupComponent (runtime-core.esm-bundler.js?5c40:7074)
    at mountComponent (runtime-core.esm-bundler.js?5c40:5079)

Below is my main.js file:

import { createApp } from 'vue'
import { fbAuth } from '@/firebase/config'

import App from '@/App.vue'
import router from '@/router'
import VTooltip from 'v-tooltip'
import 'v-tooltip/dist/v-tooltip.css'
import InstantSearch from 'vue-instantsearch/vue3/es'

let app

fbAuth.onAuthStateChanged(_user => {
    if (!app) {
        app = createApp(App)

        app.use(VTooltip, {
            defaultDelay: {
                show: 500,
                hide: 500
            }
            
        })
        app.use(InstantSearch)

        app.use(router).mount('#app')
    }
})

And here is a summary of my component:

<template>
  ...
  <ais-instant-search :search-client="searchClient" index-name="companyIndex">
    <ais-search-box />
    <ais-hits>
      <template v-slot:item="{ item }">
        <h2>{{ item.name }}</h2>
      </template>
    </ais-hits>
  </ais-instant-search>
  ...
</template>

<script>
import algoliasearch from 'algoliasearch/lite'
import { AisInstantSearch, AisSearchBox } from 'vue-instantsearch/vue3/es'
...
export default {
  name: 'Search',
  components: {
    AisInstantSearch,
    AisSearchBox,
    ...
  },
  props: [...],
  setup(props) {
    ...
    const searchClient = algoliasearch(
      '#######',
      '#######'
    )
    ...
    return {
      ...
      searchClient,
      ...
    }
  }
}
</script>

What could be causing this issue?

Answer №1

After much troubleshooting, I finally solved the issue: it turned out to be related to the version of Vue I was using. It required a minimum of 3.1.2 for vue-instantsearch to function properly, but I had been using 3.0.0! To upgrade to a newer version, you must specify the correct version for the Vue compiler. Currently, the most recent version is 3.2.20. To make this upgrade, simply include the following setting in your package.json file:

  "devDependencies": {
     ...
    "@vue/compiler-sfc": "^3.2.20"
   }

After making this change, run npm install and start your project again to ensure it compiles correctly with the updated Vue version.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The paragraph was unable to start in a new line as expected

After spending the past couple of hours scouring the internet and trying various solutions, I have come up empty-handed. My dilemma revolves around attempting to create a line break within a paragraph, but no matter what I try, it doesn't seem to work ...

Guide to integrating Firebase token authentication with a web API2 controller

In order to pass a Firebase authentication token to a web API controller, I am following steps outlined in this StackOverflow post: stackoverflowpost The bearer token is included in the $http request headers. https://i.sstatic.net/GTJz0.png Despite addr ...

Steps for setting up and shutting down the server during integration testing with Express and Supertest on NodeJS

One issue that continues to plague me is the "Address already in use::3000" error which pops up whenever I run my tests. This is what I currently have set up: package.json "scripts": { "test": "jest --watchAll --verbose --runInBand --maxWorkers=1" ...

Standardizing the file name in Internet Explorer 11 and generating a new file using JavaScript

While attempting to upload a file and normalize its name, I encountered an issue with IE11 not supporting the 'normalize' method. After some research, I discovered the 'unorm' polyfill which resolved the normalization problem. However, ...

Retrieving the data from a GET request to use in a subsequent request

I'm currently utilizing Vue to interact with an external API on a Drupal website. In order to make this interaction dynamic for each Drupal user, I need to fetch a token from Drupal first. My approach involves making two GET requests. The initial requ ...

Having difficulty getting AJAX requests or session management to work properly

I have a service that is very similar to the one discussed in this thread: Php: Form auto-fill using $_SESSION variables with multiple php files I wanted to ask my question there, but I don't have enough reputation points. So, I'm posting a new ...

What is the best way to display two radio buttons side by side in HTML?

Looking at my HTML form in this JSFiddle link, you'll see that when the PROCESS button is clicked, a form with two radio buttons appears. Currently, they are displayed vertically, with the female radio button appearing below the male radio button. I& ...

Using Javascript within AEM to update a class upon checkbox selection

I need assistance targeting the 'horizontal-video' class within a div in an AEM component. I am attempting to add a second class called 'flipped' to the div if the author clicks on a checkbox with the ID of 'coral-id-540'. Unf ...

Troubleshooting Intel Edison application update issues

After setting up the IoT XDK, I decided to try out the blink example. Excitedly, I saw that the LED on pin 13 was blinking just as expected! But when I attempted to change the interval from 1000ms to 100ms and 3000ms, there was no difference in the blinkin ...

Fresh class retains the characteristics of the former class

As I navigate my way through learning jQuery, I've encountered a puzzling issue that I can't seem to solve. No existing articles seem to address my specific problem, so I am turning to this platform in hopes of finding a solution. I'm puzz ...

Exploring Vue Components Through the Global Scope

Is it feasible to retrieve an instantiated Vue.js component object from the global JavaScript scope with Vue.js, or are these objects encapsulated within Vue's internals? For instance, when I have code defining a component like this: Vue.component(&a ...

Replicating a Bootstrap element without transferring all event listeners

Recently, I posted a query on Stack Overflow regarding the cloning of a bootstrap element while excluding the copied event listener. The solution provided was to refrain from passing true to the clone() function. Upon further reflection, I've realize ...

Dealing with jQuery hover disruption while toggling classes

I have a simple script below where I want to change the background color on hover for different buttons (regular/inactive and active) and toggle between the two states upon clicking. Although the code successfully changes the background color during hover ...

Issue with ajax.dataSrc not functioning properly in datatables

Exploring the use of the dataSrc property or manipulation method to handle table data, I am experimenting with this basic code snippet. test.php <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https ...

Localhost file not refreshing

I'm feeling quite frustrated at the moment. It seems like such a simple issue, but I can't seem to figure it out. I have created a basic webpage with a "tree-view" structure. In my readjson.js file, I am reading from a json file located in json/ ...

New to the game: validating JavaScript forms on the go

I recently developed a form that requires JavaScript validation. Despite referencing a post about inline JavaScript form validation on Stack Overflow, I struggled to replicate the desired outcomes. To aid in troubleshooting, I have set up a JSBin link tha ...

A vertical line in Javascript extending upward from the base of an element

Is there a way to create a design where an infinite vertical line extends from the bottom of a circle (or in my case, a rectangle) without using css :after or pseudo-elements? I would like the line to be its own element and not limited by the restriction ...

Transform every individual word in the paragraphs of the website into a clickable button with corresponding text on it

I've been developing a Google Chrome extension that extracts all the words from paragraphs within a web page and organizes them into buttons. This feature is just one part of a larger project I'm working on. You can check out a demo of this funct ...

What is the best way to bring in a service as a singleton class using System.js?

I have a unique Singleton-Class FooService that is loaded through a special import-map. My goal is to efficiently await its loading and then utilize it in different asynchronous functions as shown below: declare global { interface Window { System: Sy ...

The value of `this.$route.params` in Vue Router seems to be

Trying to retrieve the variable project_id from the address bar using vue-router has been a challenge. The router was set up as shown below: import Vue from 'vue' import VueRouter from 'vue-router' import App from './App' Vu ...