2017-07-28 3 views
0
import React, { Component } from 'react'; 
import { View, Text, StyleSheet, TouchableHighlight } from 'react-native'; 

class First extends Component { 
render() { 
    return (
     <View style = {styles.container}> 
      <Text> 
       Hello world! 
      </Text> 
     </View> 
    ); 
    } 
} 

const styles = StyleSheet.create ({ 
container: { 
    backgroundColor: 'yellow', 
    flex: 1 
} 
}); 


module.exports = First; 

を振る舞うFlexはreact-native initで始まったが、create-react-native-appで始まったプロジェクトで何も表示されません。これは正常ですか?はネイティブリアクト:このコードは、プロジェクトに黄色で画面いっぱいに異なっ

編集:これは、メインApp.jsのスタイルViewから誤って呼び出されました。

+0

"_ただし、同じことをしていません"、他に何がありますか? –

+0

@KhalilKhalaf何も表示されません。 –

答えて

0

それはあなたの

import React, { Component } from 'react'; 
import { View, Text, StyleSheet, TouchableHighlight } from 'react-  
native'; 

class First extends Component { 
render() { 
return (
    <View> 
     <Text style = {styles.container}> 
      Hello world! 
     </Text> 
    </View> 
    ); 
    } 
    } 

const styles = StyleSheet.create ({ 
container: { 
backgroundColor: 'yellow', 
flex: 1 
} 
}); 


module.exports = First; 
+0

同じ結果を返します。 –

+0

背景色の代わりに色を使用 –

0

を助ける私はあなたのコードを使用し、create-react-native-appを使ってアプリを作成して、上にテキストhello world!と黄色の背景色を示し、ここで私がthe-result-using-create-react-native-app

を持っていた結果を

を残しました

create-react-native-addコマンドを使用して別のテストアプリを作成し、結果を確認してください。

1

愚かな間違い;私は主なApp.jsのスタイルのViewからこのコンポーネントを呼び出していました助けに時間をとってくれてありがとう、みんな。

関連する問題