-
Notifications
You must be signed in to change notification settings - Fork 917
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: useDisplayUsdMode hook #859
Conversation
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.
Tysm @rin-st !! Tested it and works great !
Lol initally I was bit hesitant to have this hook in hooks/scaffold-eth
since seem too specific to SE-2 internal use but then realised that we have hooks like useAnimateConfig
etc too in their, not sure what the best place to keep this internal hooks but I think its fine for now !
I agree that the hooks folder is a little bit mess. Maybe in future create two folders like core (main hooks from docs) and internal/helpers/utils(all other hooks)? |
Niceee tysm @rin-st !!
Yup makes sense ! |
Description
Adds
useDisplayUsdMode
hook which helps to work with nativeCurrency/USD values.Hook takes as parameter
defaultUsdMode
which sets an initial value, and returns{ displayUsdMode, toggleDisplayUsdMode }
.toggleDisplayUsdMode
allows to change innerdisplayUsdMode
, anddisplayUsdMode
basically returns current USD mode.defaultUsdMode
anddisplayUsdMode
variables are booleans.true
meansUSD
,false
means Native Currency.See discussion here
Note:
undefined
since with it we need additional conditions likeif (typeof nativeCurrencyPrice !== "undefined" && nativeCurrencyPrice > 0)
etc.isFetching
value for price totrue
, so it's clear that if!isFetching && price === 0
then fetch failed.Additional Information