Giter Club home page Giter Club logo

vim-react-snippets's Introduction

Vim React Snippets

A Vim snippet library for React in ES6. You may also want to check out vim-es2015-snippets.

Requires UltiSnips.

vim-react-snippets

Installation

Using vim-plug:

" ES2015 code snippets (Optional)
Plug 'epilande/vim-es2015-snippets'

" React code snippets
Plug 'epilande/vim-react-snippets'

" Ultisnips
Plug 'SirVer/ultisnips'

" Trigger configuration (Optional)
" let g:UltiSnipsExpandTrigger="<C-l>"

Usage

In a JavaScript or JSX file, type a trigger name while in Insert mode, then press Ultisnips trigger key. In my case I have it mapped to <C-l>.

For example, let's say we have ListItem.js

In Insert mode

rfc<C-l>

Will expand to

import React, { PropTypes } from 'react';
import styles from './ListItem.css';

const ListItem = ({ ...props }) => (
  <div className={styles.base}>

  </div>
);

ListItem.defaultProps = {
};

ListItem.propTypes = {
};

export default ListItem;

Check out UltiSnips/javascript.snippets to see all snippets.

Snippets

Skeleton

Trigger Content
rrcc→ React Redux Class Component
rcc→ React Class Component
rfc→ React Functional Component

Lifecycle

Trigger Content
cwm→ componentWillMount() {...}
cdm→ componentDidMount() {...}
cwrp→ componentWillReceiveProps(nextProps) {...}
scup→ shouldComponentUpdate(nextProps, nextState) {...}
cwup→ componentWillUpdate(nextProps, nextState) {...}
cdup→ componentDidUpdate(prevProps, prevState) {...}
cwu→ componentWillUnmount() {...}
ren→ render() {...}

PropTypes

Trigger Content
pt→ propTypes {...}
pt.a→ PropTypes.array
pt.b→ PropTypes.bool
pt.f→ PropTypes.func
pt.n→ PropTypes.number
pt.o→ PropTypes.object
pt.s→ PropTypes.string
pt.no→ PropTypes.node
pt.e→ PropTypes.element
pt.io→ PropTypes.instanceOf
pt.one→ PropTypes.oneOf
pt.onet→ PropTypes.oneOfType (Union)
pt.ao→ PropTypes.arrayOf (Instances)
pt.oo→ PropTypes.objectOf
pt.sh→ PropTypes.shape
ir→ isRequired

Others

Trigger Content
props→ this.props
state→ this.state
set→ this.setState(...)
dp→ defaultProps {...}
cn→ className
ref→ ref

vim-react-snippets's People

Contributors

epilande avatar

Watchers

 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.