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 }) {
|
export default function Price ({ className }) {
|
||||||
const [asSats, setAsSats] = useState(undefined)
|
const [asSats, setAsSats] = useState(undefined)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setAsSats(window.localStorage.getItem('asSats'))
|
const satSelection = window.localStorage.getItem('asSats')
|
||||||
|
setAsSats(satSelection ?? 'fiat')
|
||||||
}, [])
|
}, [])
|
||||||
const { price, fiatSymbol } = usePrice()
|
const { price, fiatSymbol } = usePrice()
|
||||||
const { height: blockHeight } = useBlockHeight()
|
const { height: blockHeight } = useBlockHeight()
|
||||||
@ -62,7 +63,7 @@ export default function Price ({ className }) {
|
|||||||
setAsSats('blockHeight')
|
setAsSats('blockHeight')
|
||||||
} else if (asSats === 'blockHeight') {
|
} else if (asSats === 'blockHeight') {
|
||||||
window.localStorage.removeItem('asSats')
|
window.localStorage.removeItem('asSats')
|
||||||
setAsSats(undefined)
|
setAsSats('fiat')
|
||||||
} else {
|
} else {
|
||||||
window.localStorage.setItem('asSats', 'yep')
|
window.localStorage.setItem('asSats', 'yep')
|
||||||
setAsSats('yep')
|
setAsSats('yep')
|
||||||
@ -95,9 +96,11 @@ export default function Price ({ className }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
if (asSats === 'fiat') {
|
||||||
<div className={compClassName} onClick={handleClick} variant='link'>
|
return (
|
||||||
{fiatSymbol + fixedDecimal(price, 0)}
|
<div className={compClassName} onClick={handleClick} variant='link'>
|
||||||
</div>
|
{fiatSymbol + fixedDecimal(price, 0)}
|
||||||
)
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user