2017-04-14 3 views
0

私はreact-nativeアプリで取り組んでいます。私はreact-nativeアプリの開発のために​​テキストエディタを使用しています。どのように原子の反応ネイティブのコードを書式設定

react-nativeのコードをアトミ​​ックにフォーマットするためのショートカットが見つかりませんでした。私はパッケージhttps://atom.io/packages/atom-beautifyを美化しようとしましたが、動作しません。

import React, { 
    Component 
} from 'react'; 
import { 
    AppRegistry, 
    Image, 
    View, 
    Text, 
    Button, 
    StyleSheet 
} from 'react-native'; 

class SplashScreen extends Component { 
    render() { 
     return (< 
      View style = { 
       styles.container 
      } > 
      < 
      Image source = { 
       require('./img/talk_people.png') 
      } 
      style = { 
       { 
        width: 300, 
        height: 300 
       } 
      } 
      /> < 
      Text style = { 
       { 
        fontSize: 22, 
        textAlign: 'center', 
        marginTop: 30 
       } 
      } > Never forget to stay in touch with the people that matter to you. < /Text> < 
      View style = { 
       { 
        marginTop: 30 
       } 
      } > < Button title = "CONTINUE" 
      color = "#FE434C"/> < /View> < 
      /View> 
     ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
     backgroundColor: '#FFFFFF', 
     margin: 50, 
     alignItems: 'center', 
     flex: 1, 
     flexDirection: 'column' 
    } 
}) 

AppRegistry.registerComponent('Scheduled',() => SplashScreen); 
+0

現在、atom-beautifyはJSXをサポートしていません。問題[JSX構文(ReactJS)のサポート](https://github.com/Glavin001/atom-beautify/issues/144)の問題を参照してください。 [atom-react](https://orktes.github.io/atom-react/#indentation)パッケージを使用できます。 – Tushar

+0

@Tushar他のパッケージ? –

+0

[babel/jsx javascriptファイルでフォーマットするためにatom-beautifyパッケージを設定する方法は?](// stackoverflow.com/q/37232310) – Tushar

答えて

5

非常にお勧めしますprettier-atom

Prettier最近、多くの注目を集めており、正当な理由があります。

これはあなたのスタイルに合うように限られたオプションセットを持つ非常にストレートな、意見のついたJavaScriptフォーマッタです。さらに制御が必要な場合は、オプションのESLintインテグレーションも付属しています。

+0

ありがとうございます。出来た!! –

関連する問題