GithubHelp home page GithubHelp logo

vscode-snippets's Introduction

React-TypeScript Snippets

Simple collection of React-TypeScript Snippets.

Snippets

Import

Trigger Content
imr→ import React
imrd→ import ReactDOM

React

Trigger Content
cc→ class component
ccp→ class component with Props
ccs→ class component with State
ccc→ constructor() {…}
sfc→ stateless function component
sfcp→ stateless function component with Props
cwm→ componentWillMount() {…}
cdm→ componentDidMount() {…}
cwr→ componentWillReceiveProps() {…}
scu→ shouldComponentUpdate() {…}
cwu→ componentWillUpdate() {…}
cdu→ componentDidUpdate() {…}
cwun→ componentWillUnmount() {…}
ss→ this.setState({…})
ssf→ this.setState(() => {…})
dp→ defaultProps = {…}
refs→ refs: {…}

Full Expansions

Import

imr - import React

import * as React from 'react';

imrd - import ReactDOM

import [* as ReactDOM] from 'react-dom';

React

cc - class component

export class [FileName] extends React.Component<{}, {}> {
  render() {
    return …
  }
}

ccp - class component with Props

interface Props {}

export class [FileName] extends React.Component<Props, {}> {
  render() {
    return …
  }
}

ccs - class component with State

interface Props {}

interface State {}

export class [FileName] extends React.Component<Props, State> {
  constructor(props: Props) {
    super(props);
    this.state = {};
  }

  render() {
    return …
  }
}

ccc - constructor() {…}

constructor(props: Props) {
  super(props);
  …
}

sfc - stateless function component

export const [FileName]: React.SFC<{}> = () => {
  return …
};

sfcp - stateless function component with Props

interface Props {}

export const [FileName]: React.SFC<Props> = props => {
  return …
};

cwm - componentWillMount() {…}

componentWillMount(): void {
  …
}

cdm - componentDidMount() {…}

componentDidMount(): void {
  …
}

cwr - componentWillReceiveProps() {…}

componentWillReceiveProps(nextProps: Props): void {
  …
}

scu - shouldComponentUpdate() {…}

shouldComponentUpdate(nextProps: Props, nextState: State): boolean {
  …
}

cwu - componentWillUpdate() {…}

componentWillUpdate(nextProps: Props, nextState: State): void {
  …
}

cdu - componentDidUpdate() {…}

componentDidUpdate(prevProps: Props, prevState: State): void {
  …
}

cwun - componentWillUnmount() {…}

componentWillUnmount(): void {
  …
}

ss - setState({…})

this.setState({ … });

ssf - setState(() => {…})

this.setState((prevState: State, props: Props) => {
  …
});

dp - defaultProps = {…}

[const|static] defaultProps: Partial<Props> = {
  …
};

refs - refs: {…}

refs: {
  [key: string]: Element;
  …
};

vscode-snippets's People

Contributors

thezhir avatar

Stargazers

hongyer avatar Yony avatar Stephen Tian avatar Sigurd Fosseng avatar

Watchers

James Cloos avatar

vscode-snippets's Issues

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.