Firebase and re-base for react doesn't work

Hello,

I’m training with a video course. The code used firebase 5-5-1 and re-base 4.0.0 .
So I’m obligated to still the same versions to finish this cours.
My code is exactly the same of the video. I checked it several time.

The aim is to realize a realtime database for a chatbox.
This is the code of my base.js file:

import Rebase from 're-base';
import firebase from 'firebase/app';
import 'firebase/database';

const firebaseApp = firebase.initializeApp({
  apiKey: 'AIzaSyAi1w45FAE6PWSuWipxjVnyZ5pg0QhVjC4',
  authDomain: 'chatbox-app-4860f.firebaseapp.com',
  databaseURL:
    'https://chatbox-app-4860f-default-rtdb.europe-west1.firebasedatabase.app',
});

const base = Rebase.createClass(firebase.database());

export { firebaseApp };

export default base;

I draw your attention on the databaseURL above. It’s finish by “.app”. In the video it’s finish by ‘.com’. Maybe it’s the probleme , however I followed strictly the video during the creation of the database with firebase.

Then I import “base” component in my “App.js” like this:

import base from './base';

class App extends Component {
  state = {
    messages: {},
    pseudo: this.props.match.params.pseudo,
  };

  componentDidMount() {
    base.syncState('/', {
      context: this,
      state: 'messages',
    });
  }
....

The error message is :

./node_modules/re-base/dist/bundle.jsModule not found: Can't resolve 'firebase/app' in 'C:\Users\haddo\Documents\CODEUR\Anthony Welc - React 16+ Le Guide Complet (+Redux, React Router, Firebase)\05 - Projet 2  la Chat Box\base-chatbox-app\node_modules\re-base\dist'

what wrong with this code ?

The code is strikly the same and the dependences also. I checked all several time, all is correct.

This is my code, you can make modification as you want, it’s a forked version:

That doesn’t works anymore from the moment I try to connect whith firebase using base.js file.
In App.js file if you comment the lines under 8, you will see the code running correctly:

//import base from ‘./base’;

/componentDidMount() {
base.syncState(’/’, {
context: this,
state: ‘messages’,
});
}
/

I’m beginner and I really need help to finshed the tuto. I Know that the firebase 's version used is old but I think I am obligated to use same version that in the tuto.

What’s wrong in my code ?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.