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.
Hiep Tran
Software Developer
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.tsbut you imported the context from./auth/Contextinstead of./auth/AuthContext. The second problem I saw in your code that AuthContext may be undefined, we should use optional chaining to avoidObject is possibly 'undefined'error.