The user
object we received in response to our firebase.auth().signIn
seems like it'll be useful down the line. There may be numerous times we want access to the email of the currently signed-in user. Let's go ahead and save that in the state of our App
component so that we can then pass it down to any Container
component (once we make more containers).
There are two possible approaches: we can pass up the user object from LoginContainer
to App
via a callback through props, and App
will pass a handleLogin
function to LoginContainer
as a prop, which will be called when the user logs in and sets the state of App
appropriately.
Firebase gives us another option, however. As we discussed earlier, the Firebase database is real-time, which means changes to the data are automatically pushed to the frontend. All we need to do is set up the appropriate listener functions to wait for that change and act on it.