foo.jsは(ネイティブ定型文に反応からコードブロック):はネイティブリアクト:モジュラースタイリング
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
異なるファイルbar.jsから新しいスタイルを宣言するための最良の方法は何ですか?
1)styles
に新しいプロパティを追加しますか?
//import styles from 'foo.js'
styles.forNewComponent = {
fontSize: 30,
};
2)または、新しいStyleSheet
objを作成しますか?
const StylesforNewComponent = StyleSheet.create({
fontSize: 30,
});
1)の方法とconsole.log(styles);
を使用する場合、出力は次のようになります。
Object {container: 3, welcome: 4, instructions: 5, forNewComponent: Object}
なぜforNewComponent
の値がオブジェクトであるが、他のプロパティは、私はそれが間違っID
をやっていますか?パフォーマンスに関する問題はありますか?
感謝です! – Edgar
ようこそ。助けてうれしい) –