Skip to content

Is there a working Typescript implementation of a useToast component anywhere? #6813

Answered by LFDanLu
NickWoodward asked this question in Q&A
Discussion options

You must be logged in to vote

I've added some types here, the ToastProvider children and state wasn't typed at the top because it depends on what you will allow as the content for your Toasts as shown here: https://react-spectrum.adobe.com/react-aria/useToast.html#typescript. We could consider typing the code snippet you've mentioned in the docs, but I'm a bit concerned that people may then think that only the type we set there is allowed.

As for wrapping an app, the intention is to have the rest of your app within the ToastProvider so that the state is passed down so anything in your app could access the toast state like here. We could perhaps have a more in depth example in the docs to make this clearer.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@LFDanLu
Comment options

LFDanLu Aug 5, 2024
Collaborator

@NickWoodward
Comment options

@NickWoodward
Comment options

@LFDanLu
Comment options

LFDanLu Aug 6, 2024
Collaborator

@NickWoodward
Comment options

Answer selected by LFDanLu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants