Specify the package, or if it is a new package suggest a name.
If this covers multiple packages, if possible open an issue for both and PR separately: this will keep the PR's scope as small as possible (plus each package needs separate version bumps & republishing after the fix has been applied).
[ ] @thingco/auth-flows
[ ] @thingco/graphviz
[ ] @thingco/react-component-library
[ ] @thingco/shared-types
[ ] @thingco/unit-formatter
[ ] @thingco/user-preferences
[ ] @thingco/user-preferences-store-web
[ ] @thingco/user-preferences-store-native
[x] new package (@thingco/react-context)
Is your feature request related to a problem? Please describe.
Creating a context provider involves this pattern over and over and over again:
use createContext to create the context, with a type that is either the value or null. Create it with null.
write a provider component using Context.Provider that takes in some values as props and stores them in the context.
write a hook that wraps useContext and errors if context is undefined
Describe the solution you'd like
a createContext wrapper that returns [Provider, useProvider]
Which package is this related to?
Specify the package, or if it is a new package suggest a name.
If this covers multiple packages, if possible open an issue for both and PR separately: this will keep the PR's scope as small as possible (plus each package needs separate version bumps & republishing after the fix has been applied).
@thingco/auth-flows
@thingco/graphviz
@thingco/react-component-library
@thingco/shared-types
@thingco/unit-formatter
@thingco/user-preferences
@thingco/user-preferences-store-web
@thingco/user-preferences-store-native
@thingco/react-context
)Is your feature request related to a problem? Please describe. Creating a context provider involves this pattern over and over and over again:
createContext
to create the context, with a type that is either the value ornull
. Create it withnull
.Context.Provider
that takes in some values as props and stores them in the context.useContext
and errors if context is undefinedDescribe the solution you'd like
[Provider, useProvider]