当我要配置响应redux并在我的路线中设置连接时 组件我得到这个错误,
import React, { Component } from 'react';
import { connect } from 'react-redux'
import { Router, Scene, Actions } from 'react-native-router-flux';
import { Text, View, Image, TouchableOpacity, ImageBackground, AsyncStorage } from 'react-native';
import SendNumber from './src/container/SendNumber';
import EnterCode from './src/container/EnterCode';
import Home from './src/container/Home';
import Profile from './src/container/Profile';
import ResultItemsPage from './src/container/ResultItemsPage'
import Details from './src/container/Details'
//back button
const backButton = () => (
<TouchableOpacity
onPress={() => Actions.pop()}
style={{ width: 30, height: 20, marginLeft: 20 }}
>
<View style={{ alignItems: 'center' }}>
<Image
source={require('./Assets/Images/left-arrow.png')}
style={{ width: 30, height: 20 }}
/>
{/*
<Icon name='ios-arrow-round-back' style={{ color: '#fff' }} />
*/}
</View>
</TouchableOpacity>
);
const backButtonDetail = () => (
<TouchableOpacity
style={{
backgroundColor: '#33333320',
padding: 10,
width: 50,
height: 50,
borderRadius: 30,
justifyContent: 'center',
alignItems: 'center',
top: 10,
start: 10,
}} onPress={() => Actions.pop()} >
<Image style={{
width: 30,
resizeMode: 'contain'
}}
source={require('./Assets/Images/left-arrow-white.png')} />
</TouchableOpacity>
)
class Routes extends Component {
constructor(props) {
super(props)
this.state = {
login: false
}
}
_storeData = async () => {
try {
await AsyncStorage.setItem('login', 'true');
} catch (error) {
// Error saving data
}
};
_retrieveData = async () => {
try {
const value = await AsyncStorage.getItem('TASKS');
alert(value)
} catch (error) {
// Error retrieving data
}
};
componentWillMount() {
this._storeData();
this._retrieveData();
}
render() {
return (
<Router>
<Scene key="root" >
<Scene key="SendNumber"
component={SendNumber}
title="Send Number"
hideNavBar={true}
initial={true}
/>
<Scene key="EnterCode" component={EnterCode}
title=""
titleStyle={{ color: 'transparent' }}
renderBackButton={() => backButton()}
navigationBarStyle={styles.login_style_bar}
sceneStyle={styles.login_scene_style}
/>
<Scene key="Home"
component={Home}
title="home"
hideNavBar={true}
/>
<Scene key="Profile" component={Profile}
title=""
titleStyle={{ color: 'transparent' }}
renderBackButton={() => backButton()}
navigationBarStyle={styles.login_style_bar}
sceneStyle={styles.login_scene_style}
/>
<Scene key="ResultItemsPage" component={ResultItemsPage}
title=""
titleStyle={{ color: 'transparent' }}
renderBackButton={() => backButton()}
navigationBarStyle={styles.login_style_bar}
sceneStyle={styles.login_scene_style}
onRight={() => alert('right')}
// rightButtonImage={require('./Assets/Images/bell.png')}
renderRightButton={() => (
<TouchableOpacity style={styles.notification_box}
onPress={() => alert('توجهات')}>
<ImageBackground
style={styles.bell}
source={require('./Assets/Images/bell.png')}
>
<View style={styles.notification} >
<Text style={styles.notification_text} >3</Text>
</View>
</ImageBackground>
</TouchableOpacity>
)}
/>
<Scene key="Details" component={Details}
title=""
titleStyle={{ color: 'red' }}
renderBackButton={() => backButtonDetail()}
navigationBarStyle={styles.login_style_bar_detail}
sceneStyle={styles.login_scene_style}
/>
</Scene>
</Router >
)
}
}
const mapStateToProps = state => {
return {
status: state.number.loginStatus
}
}
export default connect(mapStateToProps)(Routes);
常量样式=({ login_style_bar:{ backgroundColor:'#f6f6f6', shadowColor:“#f7f7f7”, 海拔:0, 高度:50, }, login_style_bar_detail:{ backgroundColor:“透明”, shadowColor:“#f7f7f7”, 海拔:0, 高度:50, }, 钟声:{ 宽度:30, 高度:30, justifyContent:“中心”, alignItems:'中心', }, 通知:{ 宽度:14 高度:14 borderRadius:7 backgroundColor:'#B22850', 开始:10, 前10名, justifyContent:“中心”, alignItems:'中心', }, notification_text:{ 颜色:“#fff”, fontSize:9 fontFamily:“ ISFMedium”, }
notification_box: {
width: 40,
height: 40,
right: 20,
justifyContent: 'center',
alignItems: 'center',
},
bell: {
width: 30,
height: 30,
justifyContent: 'center',
alignItems: 'center',
},
notification: {
width: 14,
height: 14,
borderRadius: 7,
backgroundColor: '#B22850',
start: 10,
top: -10,
justifyContent: 'center',
alignItems: 'center',
},
notification_text: {
color: '#fff',
fontSize: 9,
fontFamily: 'ISFMedium',
},
})