next-firebase-auth
next-firebase-auth copied to clipboard
Export AuthUserContext to use in class based components
Describe the bug Currently migrating next-firebase-auth to canary version to improve bundle size. The project contains a mixture of function and class based component. In class based component not able to set context type to AuthUserContext as its not exported. The typescript definition file does contain that it exports AuthUserContext
Versions
next-firebase-auth version: ^1.0.0-canary.1
Firebase JS SDK: ^9.0.0
Next.js: 11.1.0
To Reproduce Steps to reproduce the behavior:
- Import AuthUserContext from package
- Use either using static contextType or Class.contextType=AuthUserContext
- Reload the page where it was added
Expected behavior AuthUserContext should be available in this.context of react component
Additional context
Did this work on 0.x and broke in canary, or does it also not work in 0.x?
If possible, could you provide a reproduction (as simple as possible) in a repository?
This doesn't work on 0.x also. Here is a repo you can see. I took the example folder as base and added a class based component in pages folder. After running the project you can visit http://localhost:3000/contextnotworking. Attaching a screenshot of what is getting logged in console. Here is the link to the repo https://github.com/mdathersajjad/nfa-context-issue

The problem is the context is not exported in the index.js file https://github.com/gladly-team/next-firebase-auth/blob/main/src/index.js#L48. I tried doing it on my own but i was getting issues with yalc and linking. If i change anything there was problem with keygrip which is used in one of the dependecies
Got it—thanks for the demo and explanation!
Closing as stale. I'm still happy to accept a contribution for this, but there's likely not much demand for it at this point.