-
-
Couldn't load subscription status.
- Fork 4.7k
docs: improve createContext documentation #16952
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
Conversation
|
|
|
I guess the context page should be updated as well |
|
There would also be the tutorial (different repository, though). |
|
this is already a bit of a side-quest 😆 I wasn't planning to do any of this yet, I just got nerd-sniped by @stolinski |
| export function getUserContext() { | ||
| return /** @type {User} */ (getContext(key)); | ||
| } | ||
| export const [getUserContext, setUserContext] = createContext<User>(); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Not too worried about the JSDoc experience tbh. If people care about type safety, and they're building an app rather than a library, they're almost certainly using .ts. And if they don't then they can do the ReturnType thing, it's fine
|
Is there a reason why
I would love to see it on the top of the Context docs as the default, recommended method. I know this is a closed issue, but I am not sure if this deserves a new issue. Will create a PR if needed. |
addresses a few points in #16948 (comment)