I am unable to use the @connect()
syntax in place of export default connect()
I've noticed that when I use the usual syntax
class PhonePage extends Component { ... }
export default connect(state => ({
testedByPhone: state.phonepage.testedByPhone
}),
(dispatch) => ({
actions: bindActionCreators(testUserPhone, dispatch)
})
)(PhonePage)
I get my state properly registered in my store.
And it looks like this: Object {screenProps: undefined, navigation: Object, testedByPhone: Object}
But when I use the @connect decorator to make things cleaner, I don't get anything listed in my state.
@connect(
state => ({
testedByPhone: state.phonepage.testedByPhone
}),
{ testUserPhone }
)
class PhonePage extends Component { ... }
export default PhonePage
Suddenly it's somehow not actually connecting things: Object {screenProps: undefined, navigation: Object}
What am I doing wrong, and what is the correct way to use the magical @connect decorator that I see everyone using?
The rest of the code, just in case it's needed, in the form of @connect;
'use strict'
import React, { Component } from 'react'
import {
AppRegistry,
StyleSheet,
Text,
ScrollView,
View,
StatusBar,
TouchableHighlight,
Button,
TextInput
} from 'react-native'
import { NavigationActions } from 'react-navigation'
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { testUserPhone } from './actions'
import PhoneInput from 'react-native-phone-input'
@connect(
state => ({
testedByPhone: state.phonepage.testedByPhone
}),
{ testUserPhone }
)
class PhonePage extends Component {
constructor(){
super()
}
componentDidMount() {
// this.props.testUserPhone
}
render() {
console.log(this.props)
return(
...
)
}
}
export default PhonePage
// export default connect(state => ({
// testedByPhone: state.phonepage.testedByPhone
// }),
// (dispatch) => ({
// actions: bindActionCreators(testUserPhone, dispatch)
// })
// )(PhonePage)
// module.exports = PhonePage