React Native error: "Can't find variable: TouchableHighlight"
React Native error: "Can't find variable: TouchableHighlight"
我正在尝试使用 Expo 在 React Native 中创建一个井字棋盘。我正在使用 TouchableHighlight 使板可触摸,以便我可以添加 X 和 O。当应用程序 运行 我收到以下错误:
"Can't find variable: TouchableHighlight"
(Board.js 12:6).
Board.js
import React, { Component } from 'react';
import { Text, View, Image, StyleSheet } from 'react-native';
export default class Board extends Component {
_onPressButton() {
console.log("you tapped the thing");
}
render() {
return (
<TouchableHighlight onPress={this._onPressButton}>
<View style={styles.container}>
<Image source = {require('./board.png')} style = {styles.table}/>
</View>
</TouchableHighlight>
);
}
}
const Xmark = (props) => (
<View>
<Image source = {require('./Xmark.png')} style = {styles.mark}/>
</View>
);
const Omark = (props) => (
<View>
<Image source = {require('./Omark.png')} style = {styles.mark}/>
</View>
);
const styles = StyleSheet.create({
container: {
flex: 6,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
table: {
height: 250,
width: 250,
},
mark: {
height: 25,
width: 25,
},
});
我还需要导入其他东西吗?我查看了其他人的代码,但没有发现任何显着差异。感谢任何帮助,谢谢。
你只需要 import { TouchableHighlight } from 'react-native'
.
我正在尝试使用 Expo 在 React Native 中创建一个井字棋盘。我正在使用 TouchableHighlight 使板可触摸,以便我可以添加 X 和 O。当应用程序 运行 我收到以下错误: "Can't find variable: TouchableHighlight" (Board.js 12:6).
Board.js
import React, { Component } from 'react';
import { Text, View, Image, StyleSheet } from 'react-native';
export default class Board extends Component {
_onPressButton() {
console.log("you tapped the thing");
}
render() {
return (
<TouchableHighlight onPress={this._onPressButton}>
<View style={styles.container}>
<Image source = {require('./board.png')} style = {styles.table}/>
</View>
</TouchableHighlight>
);
}
}
const Xmark = (props) => (
<View>
<Image source = {require('./Xmark.png')} style = {styles.mark}/>
</View>
);
const Omark = (props) => (
<View>
<Image source = {require('./Omark.png')} style = {styles.mark}/>
</View>
);
const styles = StyleSheet.create({
container: {
flex: 6,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
table: {
height: 250,
width: 250,
},
mark: {
height: 25,
width: 25,
},
});
我还需要导入其他东西吗?我查看了其他人的代码,但没有发现任何显着差异。感谢任何帮助,谢谢。
你只需要 import { TouchableHighlight } from 'react-native'
.