2017-04-13 43 views
0

我試圖創建一個井字板的陣營本地使用世博會。我使用TouchableHighlight來使電路板可觸摸,以便我可以添加X和O。當應用程序在運行,我得到以下錯誤: 「找不到變量:TouchableHighlight」 (Board.js 12:6)。陣營本機錯誤:「找不到變量:TouchableHighlight」

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, 
    }, 
}); 

有沒有別的東西,我需要進口?我看着其他人的代碼,我沒有看到任何明顯的不同。任何幫助表示讚賞,謝謝。

回答

5

你只需要import { TouchableHighlight } from 'react-native'

+0

謝謝!我認爲這會很簡單。 Facebook應該在他們的文檔中包含這一點。 –