Giter Site home page Giter Site logo

ikzjfr0 / badass-react-snippets Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tylerbuchea/badass-react-snippets

0.0 0.0 0.0 11 KB

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.

JavaScript 100.00%

badass-react-snippets's Introduction

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>
    );
  }

}

badass-react-snippets's People

Contributors

tylerbuchea avatar joshbuchea avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.