获取`[js]';' expected` 将构造函数添加到抽屉页面时
Getting `[js] ';' expected` When added Constructor to Drawer Page
我正在使用 react-navigation 模块,为什么会出现此错误:[js] ';' expected
在 DrawerNavigator 中将构造函数添加到我的 MyPhotosHomeScreen 页面时?
我想从 js 文件中读取数据,我想添加 dataSource: ds.cloneWithRows(data),
并需要添加一个构造函数。
MyPhotosHomeScreen 页面:
const MyNavScreen = ({ navigation }) => (
<View>
<View style={styles.containerNavbar}>
<TouchableHighlight onPress={() => navigation.navigate('DrawerOpen')}>
<Icon name="bars" size={30} color="#fff" />
</TouchableHighlight>
<Text style={styles.navbarTitle}>Photos</Text>
</View>
<ScrollView>
<View><Text>photo</Text></View>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</ScrollView>
<ListView
style={styles.listContainer}
renderRow={this.renderRow.bind(this)}
dataSource={this.state.dataSource}
/>
</View>
);
const MyPhotosHomeScreen = ({ navigation }) => (
<MyNavScreen navigation={navigation} />
);
MyPhotosHomeScreen.navigationOptions = {
title: 'Photos',
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="photo"
size={24}
style={{ color: tintColor }}
/>
),
};
export default MyPhotosHomeScreen;
我想添加这个构造函数:
constructor(props) {
super(props)
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 })
this.state = {
dataSource: ds.cloneWithRows(data),
}
}
机器人我遇到了这个错误:
我在 Github 页面中打开了一个问题:(https://github.com/react-community/react-navigation/issues/2218)
constructor
需要在 class...
内
我正在使用 react-navigation 模块,为什么会出现此错误:[js] ';' expected
在 DrawerNavigator 中将构造函数添加到我的 MyPhotosHomeScreen 页面时?
我想从 js 文件中读取数据,我想添加 dataSource: ds.cloneWithRows(data),
并需要添加一个构造函数。
MyPhotosHomeScreen 页面:
const MyNavScreen = ({ navigation }) => (
<View>
<View style={styles.containerNavbar}>
<TouchableHighlight onPress={() => navigation.navigate('DrawerOpen')}>
<Icon name="bars" size={30} color="#fff" />
</TouchableHighlight>
<Text style={styles.navbarTitle}>Photos</Text>
</View>
<ScrollView>
<View><Text>photo</Text></View>
<Button onPress={() => navigation.goBack(null)} title="Go back" />
</ScrollView>
<ListView
style={styles.listContainer}
renderRow={this.renderRow.bind(this)}
dataSource={this.state.dataSource}
/>
</View>
);
const MyPhotosHomeScreen = ({ navigation }) => (
<MyNavScreen navigation={navigation} />
);
MyPhotosHomeScreen.navigationOptions = {
title: 'Photos',
drawerIcon: ({ tintColor }) => (
<MaterialIcons
name="photo"
size={24}
style={{ color: tintColor }}
/>
),
};
export default MyPhotosHomeScreen;
我想添加这个构造函数:
constructor(props) {
super(props)
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 })
this.state = {
dataSource: ds.cloneWithRows(data),
}
}
机器人我遇到了这个错误:
我在 Github 页面中打开了一个问题:(https://github.com/react-community/react-navigation/issues/2218)
constructor
需要在 class...