---
title: "Discussion on \"Introduction to React Context API with Firebase Authentication\" | Hashnode"
description: "Discussion on \"Introduction to React Context API with Firebase Authentication\". Hello everyone! Today's article will be a beginner's introduction to React Context API, as I noticed that this concept is quite complex for React beginners to grasp. And I'll use Firebase Authentication to demonstrate the beauty of using React Contex..."
url: "https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Introduction to React Context API with Firebase Authentication](https://blog.lo-victoria.com/introduction-to-react-context-api-with-firebase-authentication?utm_source=hashnode&utm_medium=feed)

Hello everyone! Today's article will be a beginner's introduction to React Context API, as I noticed that this concept is quite complex for React beginners to grasp. And I'll use Firebase Authentication to demonstrate the beauty of using React Contex...

Aug 26, 2020 · 8 min read · blog.lo-victoria.com  
Updated Mar 1, 2022  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#firebase](https://hashnode.com/tag/firebase)
-   [#authentication](https://hashnode.com/tag/authentication)
-   [#beginner](https://hashnode.com/tag/beginner)

## Written by

[Victoria Lo](https://hashnode.com/@victoria)

@victoria · Singapore

  
[View profile](https://hashnode.com/@victoria)

A nerd in books, tea, games and software.

I'm a solutions engineer lead, GitHub Star, Director of WomenDevsSG, and co founder of ragTech. I work at the intersection of tech, systems, and leadership, and this blog is where I share my journey through all three. Expect honest reflections, real experiences, and thoughts that are still forming rather than polished career advice.

## Responses 2

Markdown supported · ⌘↵ to post

[Matt Heslington](https://hashnode.com/@MattHeslington)

[Sep 17, 2020](https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3/comment/5f63110d1d914f19b97de6d2)

Hi, thanks for taking the time to write this. It looks to be a super-efficient way of implementing auth to a React app.

Do you have a working example of the code, please?

Cheers!

[Victoria Lo](https://hashnode.com/@victoria)

[Sep 17, 2020](https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3/comment/5f63110d1d914f19b97de6d2#reply-5f63a62f92571222a319d42e)

Hi Matt, that's weird, the code should work. Here, I made a quick project to show it. Hope it helps.

[github.com/victoria-lo/photo-album](https://github.com/victoria-lo/photo-album)

[Matt Heslington](https://hashnode.com/@MattHeslington)

[Sep 18, 2020](https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3/comment/5f63110d1d914f19b97de6d2#reply-5f6463e928c7133624796adb)

Hello Victoria. Wow, cool project. Thank you for sharing the code! Perfect! [Victoria Lo](https://hashnode.com/@victoria)

[Bhanu Teja Pachipulusu](https://hashnode.com/@pbteja1998)

[Aug 28, 2020](https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3/comment/5f4871373ba45c3bb00eea79)

Nice article. Thanks for this.

I have seen that even though the value that you passed to the context is not a primitive value, you did not use `useMemo`.

Can you tell me what will be the implications of (not) using `useMemo` here and when do you suggest that we should use it.

Which rerenders will this `useMemo` reduces when used along with `useContext`?

[Victoria Lo](https://hashnode.com/@victoria)

[Aug 28, 2020](https://hashnode.com/posts/introduction-to-react-context-api-with-firebase-authentication/5f45c16dc71d3225c1e990e3/comment/5f4871373ba45c3bb00eea79#reply-5f495a38c736b44e8f925bd7)

Hi Bhanu, thanks for the question.

According to official docs, `useMemo` will only recompute the memoized value when one of the dependencies has changed.

In this case, `onAuthStateChanged()` does the job of useMemo so there's no need to use it.

In general, it is useful for when you need to optimize performance by avoiding expensive computation functions.

```
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
```

I will write a more detailed article in the future. Thank you!
