-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add createContextMethods
option
#55
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to this option! What is your reason to wrap the createContext method?
Sorry for late response 🙏 One use case for this is Radix UI, which uses a custom createContext method to prevent useContext from being called outside its intended scope. My team also uses similar methods, so I'd like to allow contexts created using these approaches. |
Co-authored-by: Arnaud Barré <[email protected]>
Co-authored-by: Arnaud Barré <[email protected]>
Thanks for the update. I'm still unsure on how this pattern from Radix impact source code in project that use it. Do you have an example? (I've not used Radix yet). So you also have files that have factories that create the useContext and Provider together? I'm a bit afraid that this leads to bad HMR experience. Can you provide a small example like what a simple UserContext would look like? |
This allows users to specify custom context-creating methods, in addition to the default
createContext
from React.Related: #54