()
| 167 | } |
| 168 | |
| 169 | function useToast() { |
| 170 | const [state, setState] = React.useState<State>(memoryState) |
| 171 | |
| 172 | React.useEffect(() => { |
| 173 | listeners.push(setState) |
| 174 | return () => { |
| 175 | const index = listeners.indexOf(setState) |
| 176 | if (index > -1) { |
| 177 | listeners.splice(index, 1) |
| 178 | } |
| 179 | } |
| 180 | }, [state]) |
| 181 | |
| 182 | return { |
| 183 | ...state, |
| 184 | toast, |
| 185 | dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }), |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | export { useToast, toast } |
nothing calls this directly
no test coverage detected