-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: don't hardcode toast duration #107
Conversation
✅ Deploy Preview for objective-bell-0ffbfb canceled.
|
react/src/Toast/useToast.ts
Outdated
@@ -36,7 +36,7 @@ export const useToast = ({ | |||
|
|||
const customToastImpl = useMemo(() => { | |||
const impl = ({ | |||
duration = 6000, | |||
duration = initialProps.duration, |
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.
Should we use initial duration props too for consistency?
Should we also add back the default value to prevent duration changes due to this new prop assignment?
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.
Set the default value via param defaults. Had to rename it to initialDuration
, similar to initialStatus
duration: initialDuration = 6000
...initialProps | ||
}: UseToastProps = {}): UseToastReturn => { | ||
const toast = useChakraToast(initialProps) | ||
|
||
const customToastImpl = useMemo(() => { | ||
const impl = ({ | ||
duration = 6000, | ||
duration = initialDuration, |
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.
actually this doesn't matter right? this is just a function that we return in useTOast. the user using useToast can override the props themselves (since it is just a function) don't need this PR at all right?
* fix: update vite config to fix downstream build (#103) * fix: update dropdown component to be more reliable (#106) * fix: update dropdown component to be more reliable Linked to a bunch of fixes in the upstream FormSG repository, see: opengovsg/FormSG#5192 opengovsg/FormSG#5137 opengovsg/FormSG#4922 opengovsg/FormSG#4778 * fix: remove unused dependencies * feat: don't hardcode toast duration (#107) * feat: dont hardcode toast duration * feat: set default toast duration * chore: bump package version to 0.0.13-beta.5 Co-authored-by: Kar Rui Lau <[email protected]>
Problem
Update
useToast
component to accept a duration param.