Giter Club home page Giter Club logo

atom-react-snippets's Introduction

Atom React.js Snippets Build Status

An Atom snippet library for React. This library uses ES6 syntax, if you would prefer ES5 or Coffeescript snippets please use the Atom React Package.

Install

Go to Packages > Settings View > Open once in settings go to the Install tab and search for react-snippets

Restart Atom

Development

$ cd ~/.atom/packages
$ git clone https://github.com/webbushka/atom-react-snippets.git
$ cd atom-react-snippets
$ apm install
$ apm link

Snippets

The means the TAB key

NOTE: Latest update has removed the underscore prefix
Trigger Content
im→ import empty
ir→ import react
irc→ import react and component
irp→ import react and prop-types
ipt→ import prop-types
ircp→ import react, component and prop-types
ird→ import react-dom
irs→ import react and useState
ire→ import react and useEffect
irse→ import react, useState and useEffect
ex→ export
exd→ export default
cdm→ componentDidMount method
cwm→ componentWillMount method
cwr→ componentWillReceiveProps method
scu→ shouldComponentUpdate method
cwup→ componentWillUpdate method
cdup→ componentDidUpdate method
cwun→ componentWillUnmount method
cdc→ componentDidCatch method
cx→ cx
fup→ forceUpdate
cct→ component contextTypes
cpt→ component propTypes
cdp→ component defaultProps
scct→ static component contextTypes
scpt→ static component propTypes
scdp→ static component defaultProps
cer→ class component skeleton
rsc→ stateless component skeleton
rscp→ stateless component skeleton with PropTypes
rscr→ stateless component skeleton with explicit return
rscc→ stateless component skeleton with handleClick
rsf→ stateless function
cdn→ component display name
ren→ render() method
sst→ setState()
ust→ use state const [x, setX] = useState()
props→ this.props.
state→ this.state.
rrc→ React.render()
frag→ <React.Fragment></React.Fragment>
cns→ constructor method
clss→ class extends
dnghtml→ dangerouslySetInnerHTML

In this version the PropTypes snippets prefix has changed to _pt instead of rp. All snippets have two versions to allow for required and not required types.

Trigger Content
pta→ PropTypes.array,
ptar→ PropTypes.array.isRequired,
ptb→ PropTypes.bool,
ptbr→ PropTypes.bool.isRequired,
ptf→ PropTypes.func,
ptfr→ PropTypes.func.isRequired,
ptn→ PropTypes.number,
ptnr→ PropTypes.number.isRequired,
pto→ PropTypes.object.,
ptor→ PropTypes.object.isRequired,
pts→ PropTypes.string,
ptsr→ PropTypes.string.isRequired,
ptnd→ PropTypes.node,
ptndr→ PropTypes.node.isRequired,
ptel→ PropTypes.element,
ptelr→ PropTypes.element.isRequired,
pti→ PropTypes.instanceOf(ClassName),
ptir→ PropTypes.instanceOf(ClassName).isRequired,
pte→ PropTypes.oneOf(['News', 'Photos']),
pter→ PropTypes.oneOf(['News', 'Photos']).isRequired,
ptet→ PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
ptetr→ PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
ptao→ PropTypes.arrayOf(PropTypes.number),
ptaor→ PropTypes.arrayOf(PropTypes.number).isRequired,
ptoo→ PropTypes.objectOf(PropTypes.number),
ptoor→ PropTypes.objectOf(PropTypes.number).isRequired,
ptsh→ PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}),
ptshr→ PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}).isRequired,

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

MIT License © Zeno Rocha

Credit

The React.js snippets were originally created by orktes in Atom React in ES5 syntax.

atom-react-snippets's People

Contributors

ahoseinian avatar alansouzati avatar alexkvazos avatar andreidobrinski avatar apicgg avatar bkd705 avatar designorant avatar djlechuck avatar ericchernuka avatar fluse avatar geekingreen avatar ginamdar avatar itsjw avatar jonnypickard avatar lortza avatar lucasfeliciano avatar mclark4386 avatar oieduardorabelo avatar pbojinov avatar sekhmet avatar thommymo avatar tla4 avatar webbushka avatar yakoot avatar zamabraga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

atom-react-snippets's Issues

Stateless function with support for logic/handlers

I've found myself using a React Stateless component but with support for onClick handlers and have seen a lot of examples circulate around with the same syntax as well. Here's an example.

Thoughts on adding support for something like this? And what do you think about naming?

The biggest difference between this and _rsc (Related #12) is it's wrapped in a return block with support for functions or logic above the return statement.

import React from 'react';

const Cat = ({name}) => {
    const handleClick = () => {
        console.log(`meow from ${name}`);
    };
    return (
        <div onClick={handleClick}>{name}</div>
    );
}

Cat.propTypes = {
    name: React.PropTypes.string
};

export default Cat;

Changing _rsc import style

Hi,

I was wondering if I can make a pr that changes
import React from 'react'
to
import React, {PropTypes} from 'react'

as it save writing React. before each prop we want to validate

Update router snippets to match 2.0

React Router release v2.0 and changed a lot of the API, these snippets need to be updated to match the new API.

I will get to this at some point, but wouldn't mind a PR if someone really needs this now.

React Native

Hi!

I want to add some RN snippets. How could I proceed?

not working in flow type.

i was a huge fan and used this snippets everywhere. but recently i switched to flow type javascript. and no snippets shows up then.

_cpt issue

If _cpt is meant to represent Class.propTypes = { ... }, it should instead of:

.PropTypes = {
  : React.PropTypes.string
}},

look like this:

.propTypes = {
  : React.PropTypes.string
};

Shouldn't it?

CSON syntax

Hey dude, should we use:

example: '''
  foo() {
    // code
  }
'''

Or:

example: "foo() {\n\t//code\n\t}"

I was wondering if you want a default version because you rewrote my last PR,

🎉

Enable/Disable "use strict";

Is it possible that we disable the forced use of "use strict";?

Many thanks for this very useful plugin, I still find it useful (despite it bugs me with that use strict thing).

Thanks!

Support jsx files

Is there anyway for this package to support .jsx files? It currently looks like it only supports .js files.

Adding Class.defaultProps?

Hi,

As we have React: Class.propTypes = { ... } - _cpt, why not adding, for example, React: Class.defaultProps = { ... } - _cdp for defaultProps?

Currently there is only React: getDefaultProps() { return {...} } - _gdp which can not works with class MyComposent extends React.Component {

Support for adding semicolon

Is there a way to add a configuration for your snippets to allow including semicolon, where the default option is not to have it?

If you think it makes sense, I can write a PR for that.

_cer issue

Hi, the _cer snippet seems not working. when I type cer the menu does not pop up, other snippets work fine.

Why are _rsc and _rscp identical?

I was looking for a snippet that would give me just a quick skeleton for a stateless React component. As I mainly use these for composition, they don't have PropTypes. So I was happy to see that there's a _rsc and _rscp to differentiate between stateless components with and without PropTypes. But unfortunately, both snippets contain the same content, i.e. they both generate a PropType skeleton. Why is this so?

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.