question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vuefire is either not working or the "firebase" component property is not functioning.

See original GitHub issue

I’m currently trying to create a simple firebase system for my website. This system will be used for a small forum and I set up a small testing page for vuefire and firebase. The full repo and all code (which is up to date) is here: https://github.com/ConnerFrancis/connerfrancis.github.io/tree/dev

I’ve installed firebase and vuefire with npm and the --save flag. Here are all files portaining to firebase and vuefire:

main.js

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import '@/firebase'
import VueFire from 'vuefire'
import Vue from 'vue'
import App from './App'
import router from './router'

// init Firebase with Vue
Vue.use(VueFire)

Vue.config.productionTip = false

// init Vue
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})

firebase.js

import firebase from 'firebase'

const app = firebase.initializeApp({
  apiKey: "AIzaSyA6SRssT6ut6rNLQvaLPs-4QNIsbt-mFsI",
  authDomain: "connet-702fc.firebaseapp.com",
  databaseURL: "https://connet-702fc.firebaseio.com",
  projectId: "connet-702fc",
  storageBucket: "connet-702fc.appspot.com",
  messagingSenderId: "437958455389"
})

const db = app.database()
export default db

pages/hidden/Firebase.vue

<template>
  
  <div id="firebase">
    users:
    {{ users }}
    {{ anUser }}
    <div v-for="user of users">
      {{ user.bio }}
    </div>
  </div>
  
</template>

<script>
  
  import db from '@/firebase'
  
  export default {
    name: 'Firebase',
    
    data () {
      return {
        users: {}
      }
    },
    
    firebase: {
      anUser: db.ref('users/first'), // this is a correct ref, i checked using my db browser and entering in this ref link
      
      users: {
        source: db.ref('users'),
        asObject: true,
        
        cancelCallback(err) {
          window.alert(err)
        }
      }
    }
  }
  
</script>

<style lang="scss" scoped>
  
  #firebase {
    background-color: $grey-lightest;
  }
  
</style>

When I navigate to the firebase testing page at localhost:8080/#/firebase, the users object is not populated and I get this error:

[Vue warn]: Property or method "anUser" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <Firebase> at src/pages/hidden/Firebase.vue
       <App> at src/App.vue
         <Root>

I’m not sure what I’m doing wrong here. Any help or ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
ConnerFranciscommented, May 19, 2018

Wow, you were right about the npm install 👌. I’m disappointed in myself to an extent, because I had installed the vuefire@next (I think that’s what it is) version rather than the default npm tag. Thank you so much, it’s working just fine now! 👍

To anyone else with this issue, do this: npm uninstall vuefire vuefire@next firebase --save npm install vuefire firebase --save

3reactions
posvacommented, May 19, 2018

Make sure you are using the RTDB version of vuefire (default npm tag). With that version, you don’t need to add users to data btw

Other than that I don’t see what is missing, I could take a look if you have a jsfiddle with minimal reproduction, otherwise it’s just too much

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuefire firestore() function not running to bind my data
I got VueFire to work on another app I had written, but for some reason it's just not binding in my current one....
Read more >
Vue.js Firebase Integration with VueFire - DigitalOcean
Use Firebase painlessly in your Vue.js app with VueFire.
Read more >
Watch for Vuex State changes! - DEV Community ‍ ‍
Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. I looked at ......
Read more >
How to build and deploy a Vue.js app with Cloud Firestore ...
Learn how to build and deploy a Vue.js application with CRUD functionalities two ways: using Cloud Firestore with Firebase, ...
Read more >
vuejs/vue - Gitter
It used to work, but somehow it stopped working recently. ... My understanding of functional components is no state - which sounds like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found