tylermcginnis / re-base

:fire: A Relay inspired library for building React.js + Firebase applications. :fire:
2.13k stars 143 forks source link

Not a function #259

Closed keithslater closed 6 years ago

keithslater commented 6 years ago

Getting not a function errors with a lot of the functions. These work- bindCollection, get.

These I get errors - base.remove - TypeError: __WEBPACK_IMPORTED_MODULE_3rebase.a.remove is not a function

base.removeDoc - TypeError: ref.delete is not a function

base.syncState - TypeError: __WEBPACK_IMPORTED_MODULE_3rebase.a.syncState is not a function

using rebase 4.0.0 firebase 5.3.1 firestore 0.6.1

qwales1 commented 6 years ago

@keithslater Ah yeah apologies I don't think there is anything in the docs that explains this. If you want to use both the RTDB and Firestore side by side you would need to create a re-base instance for each separately. You can see an example in the setup for this test case. It looks at which database object you passed in (RTDB or Firestore) and then exports only the functions that apply.

Edit: sorry i missed that you are also getting errors on removeDoc so maybe its actually not playing nicely with your webpack setup.

keithslater commented 6 years ago

Yeah I'm not using RTDB, I am using firebase auth though.

I'm using the create-react-app project which I guess has webpack included. I haven't customized it all.

qwales1 commented 6 years ago

ok cool will check it out. thanks for reporting

qwales1 commented 6 years ago

@keithslater I just checked with latest create-react-app and it seems to be working for me. how are you importing firebase and firestore?

keithslater commented 6 years ago

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';

var app = firebase.initializeApp({
  apiKey: '',
  authDomain: '',
  databaseURL: '',
  projectId: ''
});

const settings = {
  timestampsInSnapshots: true
};

var db = firebase.firestore(app);
db.settings(settings);
var base = Rebase.createClass(db);

export default base;`
qwales1 commented 6 years ago

that is definitely correct. is there a repo i can clone maybe?

keithslater commented 6 years ago

Ok I figured out my problem. I didn't realize that half the docs was for rtdb and half was firestore. I don't have rtdb setup so maybe that's why I was running into issues there. I changed it to do syncDoc and it looks good now. Thanks!