Vuefire is either not working or the "firebase" component property is not functioning.
See original GitHub issueI’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:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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 btwOther 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