ES7 Snippets: The Ultimate Time-Saving Tool for React Developers

React is a widely-used JavaScript library for creating dynamic and interactive user interfaces. However, writing React code can be repetitive and time-consuming. I found an extension that can help you write your code faster and more efficiently.

Tell me more about this extension

react logo

ES7+ React/Redux/React-Native snippets are a set of code snippets designed to make it easier and faster to write code in ES7+ syntax for React, Redux, and React-Native development. The snippets are short, pre-made pieces of code that you can easily insert into your code editor using a shortcut.

The snippets cover a wide range of use cases, including creating new React components, importing React and Redux libraries, accessing component props and state, and many more. They are designed to save developers time and effort by providing pre-made code snippets that can be quickly integrated into their projects.

In this post, I have gathered the most useful code snippets of this extension for React with its shortcuts, function, and output. You can install this extension from here.

Let's start it then:

'rcc', creates a react class component with a basic skeleton structure, and an import statement for react on top.

Snippet

  rcc 

output

import React, { Component } from 'react'

export default class test extends Component {
  render() {
    return (
      <div>test</div>
    )
  }
}

'rce', Creates a React component class with default export at its end.

Snippet

  rce

output

import React, { Component } from 'react'

export class test extends Component {
  render() {
    return (
      <div>test</div>
    )
  }
}

export default test

'rfc', Creates a react functional component with a basic skeleton structure.

Snippet

  rfc

output

import React from 'react'

export default function test() {
  return (
    <div>test</div>
  )
}

'rfce', Creates a react functional export component.

Snippet

  rfce

output

import React from 'react'

function test() {
  return (
    <div>test</div>
  )
}

export default test

'rafc', Creates a react arrow function component

Snippet

  rafc

output

import React from 'react'

export const test = () => {
  return (
    <div>test</div>
  )
}

'rafce', creates a react arrow function export component.

Snippet

  rafce

output

import React from 'react'

const test = () => {
  return (
    <div>test</div>
  )
}

export default test

'rconst', adds a default constructor for the class that contains props as arguments.

Snippet

  rconst

output

constructor(props) {
  super(props)

  this.state = {
     first
  }
}

Here are some more simple, but useful snippets:

SnippetsFunctionOutput
imrImport Reactimport React from 'react';
imrcImport React with Componentimport React, { Component } from 'react';
imrdImport React Domimport ReactDOM from 'react-dom';
estCreate an empty state objectthis.state = {};
propsAccess component's propsthis.props.first;
stateAccess component's statethis.state.first;
cmmbComment Big Block/** first */
clgConsole logconsole.log();
cljLogs stringified JSON property with nameconsole.log('first', JSON.stringify(first, null, 2));

To check out more snippets use CMD + Shift + R(CTRL + ALT + for Windows & Linux).

Let me know which one will be the most useful for you in the comment section below 😃.

Es7 SnippetsReact
Avatar for Muzhda Noorzad

Written by Muzhda Noorzad

Loading

Fetching comments

Hey! 👋

Got something to say?

or to leave a comment.