How to write Javascript and React with VS Code FASTER!

If you are using VS Code to write Javascript or React code, keep reading!

VS Code is my favourite code editor and I use it mostly to write Javascript and React code.

Since I use it a lot, I have picked up few things that make my life easier as a Javascript and React developer. One of them is code snippets!

See also: TOP 10 Keyboard Shortcuts For Visual Studio Code

Code snippets are great because they save me from having to write same boilerplate code, for example when creating a React component or defining a for loop, over and over again.

You just type in the prefix for the code you want to generate and press enter and voalá, you got your code written instantly!

On the video below, I will show you how you can get started on using React and Javascript code snippets with Visual Studio Code in a matter of minutes! I will also share bunch of my favourite and most used snippets that I use every day.

How to write Javascript and React with VS Code FASTER! (using code snippets)

If you rather read, here is a short summary of the video. (I still recommend you check the video out, and if you like it please do subscribe to my Youtube channel also, I would really appreciate it!).

In VS Code, you can create your own snippets. But that is not necessary, because you can also install an extension that provides code snippets you want.

There is a great extension for Javascrit & React code snippets called VS Code ES7 React/Redux/React-Native/JS snippets and you can install it from the extensions tab in your Visual Studio Code.

After installing the extension, you can start using the snippets right away! Snippets can be used with prefixes listed in the extension page. You just type in the prefix in the file you are editing and press enter and the snippet is automatically generated.

Here are couple of my favourite snippets:


1for(let itemName in objectName { }


1const functionName = (params) => {};




1import React from "react";


1import React, { Component } from "react";


1import { BrowserRouter as Router, Route, NavLink } from "react-router-dom";


1componentDidMount = () => {};


1componentDidUpdate = (prevProps, prevState) => {};


1import React, { Component } from "react";
3export default class FileName extends Component {
4  render() {
5    return <div>$2</div>;
6  }


1import React, { PureComponent } from "react";
2import PropTypes from "prop-types";
4export default class FileName extends PureComponent {
5  static propTypes = {};
7  render() {
8    return <div>$2</div>;
9  }


1import React, { Component } from "react";
2import { connect } from "react-redux";
4export class FileName extends Component {
5  render() {
6    return <div>$4</div>;
7  }
10const mapStateToProps = (state) => ({});
12const mapDispatchToProps = {};
14export default connect(mapStateToProps, mapDispatchToProps)(FileName);

Wrapping up

Code snippets really save keystrokes and that way also your time and you can code faster and be more efficient.

Are you using code snippets? Comment below your favourite code snippets!

PS. If you are new to React or someone who has just started using it, you should check out my React Basics course on Skillshare. You can now get it for free when registering to Skillshare through this link.

Read next:
If you want to learn more, make sure to subscribe on Youtube!

Subscribe to the newsletter