docs: improve createContext documentation#16952
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.
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)