Toast.Trigger component for uncontrolled orchestration? #2907
Unanswered
afzalsayed96
asked this question in
Help
Replies: 1 comment
-
@afzalsayed96 toasts are usually triggered in response to a side effect that has occurred in your application, whereas for instance you might do something like this: const [isToastOpen, setIsToastOpen] = React.useState(false);
const handleButtonClick = () => {
if (someSideEffectSucceeded) setIsToastOpen(true);
};
return (
<div>
<button onClick={handleButtonClick}>Go</button>
<Toast.Root open={isToastOpen} onOpenChange={setIsToastOpen}>{/* ... */}</Toast.Root>
</div>
); the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Having used other radix-ui primitives like dialog and popover, I feel a bit lost about using Toast in an uncontrolled manner.
Why doesn't
Toast
have aTrigger
component similar toDialog
,Popover
and other primitives?Beta Was this translation helpful? Give feedback.
All reactions