From d0bb9cbbacc192e850f65770fdf9a1739973e9f3 Mon Sep 17 00:00:00 2001 From: slowbackspace Date: Tue, 12 Mar 2019 18:13:38 +0100 Subject: [PATCH] separate presentational from container component --- .../Wallet/views/WalletSettings/Container.js | 44 ++++++++++++++++++ .../Wallet/views/WalletSettings/index.js | 45 ++----------------- src/views/index.js | 2 +- 3 files changed, 49 insertions(+), 42 deletions(-) create mode 100644 src/views/Wallet/views/WalletSettings/Container.js diff --git a/src/views/Wallet/views/WalletSettings/Container.js b/src/views/Wallet/views/WalletSettings/Container.js new file mode 100644 index 00000000..24e5c4d0 --- /dev/null +++ b/src/views/Wallet/views/WalletSettings/Container.js @@ -0,0 +1,44 @@ +/* @flow */ +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { injectIntl } from 'react-intl'; + +import * as WalletActions from 'actions/WalletActions'; +import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; +import type { State, Dispatch } from 'flowtype'; +import WalletSettings from './index'; + +type OwnProps = {}; + +type StateProps = { + wallet: $ElementType, + fiat: $ElementType, + localStorage: $ElementType, +}; + +type DispatchProps = { + setLocalCurrency: typeof WalletActions.setLocalCurrency, +}; + +export type Props = StateProps & DispatchProps; + +const mapStateToProps: MapStateToProps = ( + state: State +): StateProps => ({ + wallet: state.wallet, + fiat: state.fiat, + localStorage: state.localStorage, +}); + +const mapDispatchToProps: MapDispatchToProps = ( + dispatch: Dispatch +): DispatchProps => ({ + setLocalCurrency: bindActionCreators(WalletActions.setLocalCurrency, dispatch), +}); + +export default injectIntl( + connect( + mapStateToProps, + mapDispatchToProps + )(WalletSettings) +); diff --git a/src/views/Wallet/views/WalletSettings/index.js b/src/views/Wallet/views/WalletSettings/index.js index c8e76aeb..91ddd07b 100644 --- a/src/views/Wallet/views/WalletSettings/index.js +++ b/src/views/Wallet/views/WalletSettings/index.js @@ -1,13 +1,7 @@ /* @flow */ import styled from 'styled-components'; import React from 'react'; -import { connect } from 'react-redux'; -import { bindActionCreators } from 'redux'; -import { FormattedMessage, injectIntl } from 'react-intl'; - -import * as WalletActions from 'actions/WalletActions'; -import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; -import type { State, Dispatch } from 'flowtype'; +import { FormattedMessage } from 'react-intl'; import Link from 'components/Link'; import Content from 'views/Wallet/components/Content'; @@ -19,6 +13,7 @@ import { FIAT_CURRENCIES } from 'config/app'; import { FONT_SIZE } from 'config/variables'; import l10nCommonMessages from 'views/common.messages'; import l10nMessages from './index.messages'; +import type { Props } from './Container'; const CurrencySelect = styled(Select)` min-width: 77px; @@ -56,6 +51,7 @@ const buildCurrencyOption = currency => { const WalletSettings = (props: Props) => ( + {console.log(props)}
@@ -83,37 +79,4 @@ const WalletSettings = (props: Props) => ( ); -type OwnProps = {}; - -type StateProps = { - wallet: $ElementType, - fiat: $ElementType, - localStorage: $ElementType, -}; - -type DispatchProps = { - setLocalCurrency: typeof WalletActions.setLocalCurrency, -}; - -export type Props = StateProps & DispatchProps; - -const mapStateToProps: MapStateToProps = ( - state: State -): StateProps => ({ - wallet: state.wallet, - fiat: state.fiat, - localStorage: state.localStorage, -}); - -const mapDispatchToProps: MapDispatchToProps = ( - dispatch: Dispatch -): DispatchProps => ({ - setLocalCurrency: bindActionCreators(WalletActions.setLocalCurrency, dispatch), -}); - -export default injectIntl( - connect( - mapStateToProps, - mapDispatchToProps - )(WalletSettings) -); +export default WalletSettings; diff --git a/src/views/index.js b/src/views/index.js index ffd741c9..fa73d779 100644 --- a/src/views/index.js +++ b/src/views/index.js @@ -25,7 +25,7 @@ import AccountSignVerify from 'views/Wallet/views/Account/SignVerify/Container'; import WalletDashboard from 'views/Wallet/views/Dashboard'; import WalletDeviceSettings from 'views/Wallet/views/DeviceSettings'; -import WalletSettings from 'views/Wallet/views/WalletSettings'; +import WalletSettings from 'views/Wallet/views/WalletSettings/Container'; import WalletBootloader from 'views/Wallet/views/Bootloader'; import WalletFirmwareUpdate from 'views/Wallet/views/FirmwareUpdate'; import WalletNoBackup from 'views/Wallet/views/NoBackup';