From the course: React: Cloud-Powered Apps with Firebase

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Displaying current user

Displaying current user

From the course: React: Cloud-Powered Apps with Firebase

Start my 1-month free trial

Displaying current user

- [Instructor] Now that we have implemented user signup, wanting to be able to display the currently authenticated user. It will also provide a better user experience if the user gets routed to a profile page where they can see their information. Let's do that now. But first, we need to be able to get the current authenticated session and be able to access that in any component. We will do so by leveraging react context. And then child components will leverage hooks to access the user session. Let's start by creating a new file under the firebase folder here and call it UserProvider.js. We will use this file to house the user context, a provider component, and also a hook to access a current user session. First let's import React. And then the useEffect, useState, and useContext hooks from react. Also let's import firebase from firebase/app. We can create our user context by calling React.createContext. Now…

Contents