Dont display price component until after initial render (#637)
* Dont display price component until after initial render * change variable name and remove log * fix linting issues --------- Co-authored-by: stargut <stargut@starguts-MBP.fios-router.home> Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
This commit is contained in:
parent
92ec6be20a
commit
d84c46df81
|
@ -44,7 +44,8 @@ export function PriceProvider ({ price, children }) {
|
|||
export default function Price ({ className }) {
|
||||
const [asSats, setAsSats] = useState(undefined)
|
||||
useEffect(() => {
|
||||
setAsSats(window.localStorage.getItem('asSats'))
|
||||
const satSelection = window.localStorage.getItem('asSats')
|
||||
setAsSats(satSelection ?? 'fiat')
|
||||
}, [])
|
||||
const { price, fiatSymbol } = usePrice()
|
||||
const { height: blockHeight } = useBlockHeight()
|
||||
|
@ -62,7 +63,7 @@ export default function Price ({ className }) {
|
|||
setAsSats('blockHeight')
|
||||
} else if (asSats === 'blockHeight') {
|
||||
window.localStorage.removeItem('asSats')
|
||||
setAsSats(undefined)
|
||||
setAsSats('fiat')
|
||||
} else {
|
||||
window.localStorage.setItem('asSats', 'yep')
|
||||
setAsSats('yep')
|
||||
|
@ -95,9 +96,11 @@ export default function Price ({ className }) {
|
|||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={compClassName} onClick={handleClick} variant='link'>
|
||||
{fiatSymbol + fixedDecimal(price, 0)}
|
||||
</div>
|
||||
)
|
||||
if (asSats === 'fiat') {
|
||||
return (
|
||||
<div className={compClassName} onClick={handleClick} variant='link'>
|
||||
{fiatSymbol + fixedDecimal(price, 0)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue