Skip to content

Package for Github's Atom Editor. These snippets are made to work with the latest ES6 standards, adhere to the airbnb eslint config, and are React/React-Native agnostic.

Notifications You must be signed in to change notification settings

tylerthebuildor/badass-react-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Badass React Snippets Build Status

Package for Github's Atom Editor

About

These snippets are made to work with the latest ES6 standards, adhere to the airbnb eslint config, and are React/React-Native agnostic.

Add the airbnb eslint config to your project (optional)

npm install --save-dev eslint eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y
echo '\''{ extends: [airbnb], }'\'' > .eslintrc'

Installation

apm install badass-react-snippets

Usage

After install just type one of the titles below and hit tab then the snippet will expand in your editor. Only works on files already saved as .js or .jsx

Continue hitting tab to cycle through and highlight common editing points in a component.

rcc

React ES6 Component with Constructor

import React, {
  Component,
  PropTypes,
} from 'react';

import {
  View,
} from 'react-native';

const propTypes = {};

const defaultProps = {};

export default class MyComponent extends Component {

  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    return (
      <div>
        <h1>Title</h1>
      </div>
    );
  }

}

MyComponent.propTypes = propTypes;
MyComponent.defaultProps = defaultProps;

rc

React ES6 Component

import React, {
  Component,
  PropTypes,
} from 'react';

import {
  View,
} from 'react-native';

const propTypes = {};

const defaultProps = {};

export default class MyComponent extends Component {

  render() {
    return (
      <div>
        <h1>Title</h1>
      </div>
    );
  }

}

MyComponent.propTypes = propTypes;
MyComponent.defaultProps = defaultProps;

rfunc

React ES6 Functional Component

import React, {
  PropTypes,
} from 'react';

import {
  View,
} from 'react-native';

const propTypes = {};

const defaultProps = {};

export default function MyComponent(props) {
  return (
    <div>
      <h1>Title</h1>
    </div>
  );
}

MyComponent.propTypes = propTypes;
MyComponent.defaultProps = defaultProps;

rconst

React ES6 Constructor

constructor(props) {
  super(props);
  this.state = {
    someVariable,
  };
}

rbm

React ES6 bind method to this

this.someMethod = this.someMethod.bind(this);

rcc7

React ES7 Component with Constructor using static. Not airbnb compliant.

import React, {
  Component,
  PropTypes,
} from 'react';

import {
  View,
} from 'react-native';

export default class MyComponent extends Component {

  static defaultProps = {}

  static propTypes = {}

  constructor(props) {
    super(props);
    this.state = {};
  }

  render() {
    return (
      <div>
        <h1>Title</h1>
      </div>
    );
  }

}

About

Package for Github's Atom Editor. These snippets are made to work with the latest ES6 standards, adhere to the airbnb eslint config, and are React/React-Native agnostic.

Resources

Stars

Watchers

Forks

Packages

No packages published