---
title: "Comment by Hiep Tran on \"The advanced guide to React Context with hooks.\" | Hashnode"
description: "Hi there, Thank you for your content, I&#39;ve learned a lot from your post. However, I see you make some mistakes during using auth context. First, you created"
url: "https://hashnode.com/posts/the-advanced-guide-to-react-context-with-hooks/6057bf4f63a05a21443f3717/comment/6058085163a05a21443f397f"
---

[Discussion](https://hashnode.com/posts/the-advanced-guide-to-react-context-with-hooks/6057bf4f63a05a21443f3717)

Comment [The advanced guide to React Context with hooks.](https://hashnode.com/posts/the-advanced-guide-to-react-context-with-hooks/6057bf4f63a05a21443f3717)

[Hiep Tran](https://hashnode.com/@tranhiepqna)

[Mar 22, 2021](https://hashnode.com/posts/the-advanced-guide-to-react-context-with-hooks/6057bf4f63a05a21443f3717/comment/6058085163a05a21443f397f)

Hi there, Thank you for your content, I've learned a lot from your post. However, I see you make some mistakes during using auth context. First, you created auth context in `src/auth/AuthContext.ts` but you imported the context from `./auth/Context` instead of `./auth/AuthContext`. The second problem I saw in your code that AuthContext may be undefined, we should use [optional chaining](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#optional-chaining) to avoid `Object is possibly 'undefined'` error.

[CodeReviewIo](https://hashnode.com/@codeReviewIo)

[Mar 22, 2021](https://hashnode.com/posts/the-advanced-guide-to-react-context-with-hooks/6057bf4f63a05a21443f3717/comment/6058085163a05a21443f397f#reply-6058f4305771a2129446a7fb)

Thank you, I have updated it. For context value: this actually should be `defaultValue` not undefined but in this case we have to provide full initial data consider it `initialState`. So, the solution that we provide `undefined` or make all the contextValues optional and then pass `defaultState` I would say in this case it depends to your project.👍 Happy that helps.
