Skip to content

bestwestern/simple-react-snippets

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple React Snippets

The essential collection of React Snippets.

snippets in action

Features

Only what you need and nothing more. No Redux. No React Native.

Simply, simple React snippets.

These snippets were selected carefully from my own day-to-day React use. Not everything in React is included here. This is a hand selected set of snippets that work the way that you would expect, not just a copy of the documentation.

Snippets

Snippet Renders
imr Import React
imrc Import React / Component
cc Class Component
ccc Class Component With Constructor
sfc Stateless Function Component
cdm componentDidMount
cwm componentWillMount
cwrp componentWillReceiveProps
scu shouldComponentUpdate
cwu componentWillUpdate
cdu componentDidUpdate
cwu componentWillUpdate
ss setState
ren render

Full Expansions

imr - Import React

import React from 'react';

imrc - Import React, Component

import React, { Component } from 'react';

cc - Class Component

class MyClass extends Component {
  render() {
    return <div />;
  }
}

export default MyClass;

ccc - Class Component With State

class MyClass extends Component {
  constructor(props) {
    super(props);
    this.state = { };
  }
  render() {
    return <div />;
  }
}

export default MyClass;

sfc - Stateless Function Component

const MyComponent = props => {
  return <div />;
};

export default MyComponent;

cdm - componentDidMount

componentDidMount() {

}

cwm - componentWillMount

componentWillMount() {

}

cwrp - componentWillReceiveProps

componentWillReceiveProps(nextProps) {

}

scu - shouldComponentUpdate

shouldComponentUpdate(nextProps, nextState) {

}

cwu - componentWillUpdate

componentWillUpdate() {

}

cdu - componentDidUpdate

componentDidUpdate(prevProps) {

}

cwun - componentWillUnmount

componentWillUnmount() {

}

ss - setState

this.setState({  :  });  

ren - render

render() {
  return (
      
  )
}

Release Notes

1.0.2

  • Change "Create Class With Constructor" to "Create Class With State"
  • Pass props to constructor and super call
  • Add this.state to constructor
  • Pass prevProps to componentDidUpdate

1.0.1

Complete README with samples

1.0.0

Initial release of Simple React Snippets 🔥

About

Simple React Snippets for VS Code that you will actually use

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published