Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format code of react native in atom

I am working on react-native app. I am using atom text editor for the development of react-native apps.

I did not find any shortcut to format react-native code in atom. I tried beautify package https://atom.io/packages/atom-beautify but it is not working.

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);
like image 412
N Sharma Avatar asked Apr 14 '17 10:04

N Sharma


People also ask

How do you arrange codes in Atom?

Format a selection of code using the code-format:format-code ( CTRL+SHIFT+C ) command. (Also accessible via context menu, or "Edit > Text > Format Code"). When no selection is provided, the entire file is formatted.

How do I beautify text in an Atom?

To Format text Using atom-beautify :Hit Ctrl + Alt + B ( Ctrl + Option + B on mac).

Does Atom support React Native?

atom-react-native-css – It is a package to style React-Native components with built-in support for SASS/SCSS. React-native-css turns valid CSS/SASS into the Facebook subset of CSS. react-native-snippets – It is a package for React Native snippets for Atom.

How do I run React Native app in Atom?

Open Atom preferences and go to Install tab. Here you can search and install each of the packages mentioned below and get ready to code your mobile applications in React Native. I have tried to keep the plugins to minimum, so as not to clutter Atom.


1 Answers

I highly recommend prettier-atom.

Prettier has been getting a lot of attention lately, and for a good reason.

It's a very straight forward, opinionated JavaScript formatter with a limited set of options to suit your style. It also comes with an optional ESLint integration if you need more control.

like image 72
designorant Avatar answered Sep 23 '22 16:09

designorant