From 1e1dac4f8f9940ec1d3349f61b646ca3d50f2e8e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 5 Apr 2019 15:39:32 +0200 Subject: [PATCH] refactor popover --- .../molecules/AccountStatus/Popover.tsx | 67 +++++++++---------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/client/src/components/molecules/AccountStatus/Popover.tsx b/client/src/components/molecules/AccountStatus/Popover.tsx index e8c3541..c0af1bf 100644 --- a/client/src/components/molecules/AccountStatus/Popover.tsx +++ b/client/src/components/molecules/AccountStatus/Popover.tsx @@ -1,59 +1,52 @@ -import React from 'react' +import React, { PureComponent } from 'react' import { User } from '../../../context/User' import styles from './Popover.module.scss' -const Popover = ({ - forwardedRef, - style -}: { +export default class Popover extends PureComponent<{ forwardedRef: (ref: HTMLElement | null) => void style: React.CSSProperties -}) => ( -
- - {states => - states.account && - states.balance && ( +}> { + public render() { + const { account, balance, network } = this.context + return ( +
+ {account && balance && (
- {(states.balance.eth / 1e18) - .toFixed(3) - .slice(0, -1)} + {(balance.eth / 1e18).toFixed(3).slice(0, -1)} {' '} ETH - {states.balance.ocn} OCEAN + {balance.ocn} OCEAN
- ) - } - + )} -
- - {states => - states.account ? ( - - {states.account} +
+ {account ? ( + + {account} ) : ( No account selected - ) - } - -
+ )} +
-
- - {states => states.network && states.network} - -
-
-) +
+ {network && network} +
+
+ ) + } +} -export default Popover +Popover.contextType = User