O'Reilly logo

Progressive Web Apps with React by Scott Domes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading data from Firebase

As we described earlier, we can listen for changes to a particular reference in our database. In other words, we can define a function to run every time firebase.database().ref(‘/messages’) changes, as a new message comes in.

Before we move on, I'd encourage you to consider two things: where we should define this listener, and what the function should do.

See if you can come up with a possible implementation! After you've brainstormed an idea, let's build it.

Here's the thing: we already have a very similar case in our application. Our firebase.auth().onAuthStateChanged in our App#componentDidMount listens for changes in our current user, and updates the state.user of our App.

We will do the exact same thing with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required