Commit 2cc2fed8 authored by Marek Kotewicz's avatar Marek Kotewicz
Browse files

use first reducer to addAccount

parent 3c1b9305
import { ADD_ACCOUNT } from '../constants/AccountActions'
export function addAccount(account) {
return {
type: ADD_ACCOUNT,
address: account.address,
}
}
......@@ -15,6 +15,12 @@ export default class AccountsList extends Component {
}
}
componentWillReceiveProps(nextProps) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.accounts)
})
}
render() {
return (
<ListView
......
......@@ -52,4 +52,3 @@ export default class App extends Component {
)
}
}
import React, { Component } from 'react'
import { View, Text, Button, StyleSheet } from 'react-native'
import { connect } from 'react-redux'
import { Actions } from 'react-native-router-flux'
import debounce from 'debounce'
import NewAccountInput from '../components/NewAccountInput'
import { words } from '../actions/random'
import { keypairFromPhrase, toAddress } from '../actions/crypto'
import { addAccount } from '../actions/accounts'
//const addAccount = (dispatch) => {
//return {
//onAddAccount: (keypair) => {
//}
//}
//}
const mapDispatchToProps = (dispatch) => {
return {
addAccount: (keypair) => {
const address = toAddress(keypair)
dispatch(addAccount({
address: address
}))
Actions.pop()
}
}
}
export default class NewAccount extends Component {
export class NewAccount extends Component {
constructor(props) {
super(props)
......@@ -34,7 +41,7 @@ export default class NewAccount extends Component {
}/>
<Text>0x{toAddress(this.state.keypair)}</Text>
<Button
onPress={() => {}}
onPress={() => this.props.addAccount(this.state.keypair)}
title="Add Account"
color="#841584"
accessibilityLabel="Press to add new account"
......@@ -52,3 +59,9 @@ const styles = StyleSheet.create({
padding: 10
},
})
export default connect(
undefined,
mapDispatchToProps
)(NewAccount)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment