-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add useToast hook for toast notifications #3593
Conversation
5173f4c
to
cefb523
Compare
Removed vultr server and associated DNS entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor / very handy 🙌 🍞
}: Readonly<{ children: ReactNode }>) => { | ||
const [state, dispatch] = useReducer(toastReducer, initialState); | ||
const addToast = (type: ToastType, message: string) => { | ||
const id = Math.floor(Math.random() * 10_000_000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we also have the uuid
package available on the frontend which would let you generate a unique uuid id like const id = uuidV4()
(consistent with how we generate session ids) - happy for this to work either way though / chances of unintentionally colliding/non-unique IDs seems veryyy low here 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice tip thanks! I'll include that in the next PR 👍
default: | ||
// @ts-ignore | ||
// Typescript complains because action is of type 'never' here | ||
throw new Error(`Unhandled action type: ${action.type}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
What is this?
Replacing everywhere we use:
With
toast.success(message)
🎉Testing
An easy place to test this is in the Team Members page, when you've successfully added a new editor. You should see the usual toast message pop up on success.