Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
2cc2fed8
Commit
2cc2fed8
authored
Feb 09, 2017
by
Marek Kotewicz
Browse files
use first reducer to addAccount
parent
3c1b9305
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/actions/accounts.js
0 → 100644
View file @
2cc2fed8
import
{
ADD_ACCOUNT
}
from
'
../constants/AccountActions
'
export
function
addAccount
(
account
)
{
return
{
type
:
ADD_ACCOUNT
,
address
:
account
.
address
,
}
}
src/components/AccountsList.js
View file @
2cc2fed8
...
...
@@ -15,6 +15,12 @@ export default class AccountsList extends Component {
}
}
componentWillReceiveProps
(
nextProps
)
{
this
.
setState
({
dataSource
:
this
.
state
.
dataSource
.
cloneWithRows
(
nextProps
.
accounts
)
})
}
render
()
{
return
(
<
ListView
...
...
src/components/App.js
View file @
2cc2fed8
...
...
@@ -52,4 +52,3 @@ export default class App extends Component {
)
}
}
src/containers/NewAccount.js
View file @
2cc2fed8
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
>
0
x
{
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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment