Toast onOpenChange
not being called
#2195
-
I'm trying to control the state of the toast, but I'm not seeing that
What am I missing? From the docs, it does appear that I should be able to control the state, right? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @stevecastaneda, when you are controlling a prop, you tell the component what value that prop should be (so here Now, consider that So you will never see This is how any controlled prop work in React. Think about Hopefully this makes some sense. ✌️ |
Beta Was this translation helpful? Give feedback.
Hey @stevecastaneda, when you are controlling a prop, you tell the component what value that prop should be (so here
open
tells the component when it should be open). The component then tells you when "it" has made changes internally, via a callback, essentially telling you to update the value your side (so hereonOpenChange
).Now, consider that
Toast
never needs to tell you it needs to "open", because you have told it to open, it will however tell you when it needs to close (for example when the timer expires, or when the close button is pressed).So you will never see
onOpenChange
being called withtrue
.This is how any controlled prop work in React. Think about
value
,onChange
on aninput