dev.rean.me
react-js

VS Code ReactJS Shorthand & Snippets — Complete Guide with Tips

Master ReactJS code snippets, ES7+ shortcuts, hooks shorthands, JSX Emmet configuration, custom React snippets, and VS Code productivity tips.

2026-09-11 · 8 min read

Share:

VS Code ReactJS Shorthand & Snippets — Code React 10× Faster!

Hello friend! Writing React functional components, hooks (useState, useEffect), and JSX boilerplate manually takes a lot of repetitive typing.

Did you know that with VS Code snippets and shortcuts, you can create a full React component in 1 second by typing just rafce + Tab?

In this complete guide, we cover all essential ReactJS shorthands, component templates, React Hooks shortcuts, JSX Emmet configuration, and pro tips to supercharge your React workflow!

💡 Pro Tip: Make sure to install the extension ES7+ React/Redux/React-Native snippets in VS Code to unlock all of these shortcuts!

If you want to explore more ReactJS, JS, HTML & CSS guides:


1. Component Generation Shorthands

These are the most famous React snippets used by millions of frontend developers every day:

ShorthandOutput / Expands ToDescription
rafceArrow Functional Component + Export DefaultMost popular! Creates const Component = () => {} and exports default
rfceRegular Functional Component + Export DefaultCreates function Component() {} and exports default
rafcArrow Functional ComponentCreates arrow component without export default
rfcRegular Functional ComponentCreates regular function component without export default
tsrafceTypeScript Arrow ComponentArrow component with TypeScript interface
tsrfceTypeScript Function ComponentFunction component with TypeScript interface

Example 1: rafce (Arrow Component + Export Default)

Type: rafce + Tab in a file named UserProfile.jsx

Expands to:

import React from 'react'

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

export default UserProfile

Example 2: rfce (Regular Function Component)

Type: rfce + Tab

Expands to:

import React from 'react'

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

export default UserProfile

2. React Hooks Shorthands

Instead of writing state and effect hooks manually, use these 3-letter shortcuts:

ShorthandExpands ToDescription
usf or useStateconst [state, setState] = useState(initialState)useState Hook
uef or useEffectuseEffect(() => { ... }, [])useEffect Hook
ucf or useContextconst value = useContext(MyContext)useContext Hook
urf or useRefconst refContainer = useRef(initialValue)useRef Hook
umf or useMemoconst memoizedValue = useMemo(() => compute(), [deps])useMemo Hook
ucb or useCallbackconst memoizedCallback = useCallback(() => {}, [deps])useCallback Hook
ure or useReducerconst [state, dispatch] = useReducer(reducer, initial)useReducer Hook

usf — useState Shortcut

Type: usf + Tab

Expands to:

const [name, setName] = useState(initialState)

uef — useEffect Shortcut

Type: uef + Tab

Expands to:

useEffect(() => {
  
  return () => {
    
  }
}, [])

3. Enable Emmet Shorthands in JSX / TSX

Emmet HTML shortcuts (like div.card>h2.title+p.text) do not work in React .jsx or .tsx files by default in VS Code.

How to Enable Emmet in React JSX:

Open your VS Code settings.json file and add this configuration:

{
  "emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "javascriptreact": "html",
    "typescriptreact": "html"
  },
  "emmet.syntaxProfiles": {
    "javascript": "jsx"
  }
}

Now you can use full Emmet inside React JSX components!

Type in JSX:

div.user-card>img.avatar+h3.name+button.btn-primary{Follow}

Press Tab → Expands to:

<div className="user-card">
  <img src="" alt="" className="avatar" />
  <h3 className="name"></h3>
  <button className="btn-primary">Follow</button>
</div>

💡 Notice: Emmet in JSX automatically converts class to className!


4. Props & Event Handler Shorthands

Destructuring Props in Component Signature

Instead of writing props.name and props.age, destructure directly inside parameter brackets:

// Quick signature shorthand:
const UserCard = ({ name, age, avatar, onFollow }) => {
  return (
    <div className="user-card">
      <img src={avatar} alt={name} />
      <h2>{name}</h2>
      <p>Age: {age}</p>
      <button onClick={onFollow}>Follow</button>
    </div>
  );
};

Common Event Handlers Shorthands

Event HandlerInline JSX Shorthand
Click Event<button onClick={() => handleClick(id)}>Click</button>
Input Change<input onChange={(e) => setName(e.target.value)} />
Form Submit<form onSubmit={handleSubmit}>

5. Essential VS Code Extensions for ReactJS

Install these top extensions to make React development smooth and fast:

1. ES7+ React/Redux/React-Native snippets

  • Marketplace ID: dsznajder.es7-react-js-snippets
  • Why you need it: Provides rafce, rfce, usf, uef, and all standard React shortcuts.

2. Auto Rename Tag

  • Marketplace ID: formulahendry.auto-rename-tag
  • Why you need it: When you rename opening tag <Header> to <Navigation>, it automatically updates matching closing tag </Navigation>!

3. VSCode React Refactor

  • Marketplace ID: czm.vscode-react-refactor
  • Why you need it: Select any chunk of JSX → Right-click → "Extract to Component". It automatically moves that JSX into a separate React component file!

4. Simple React Snippets

  • Marketplace ID: burkeholland.simple-react-snippets
  • Why you need it: Lightweight alternative for super clean component templates.

6. How to Create Custom React Snippets in VS Code

Want a custom snippet for your team's component structure or custom hooks?

Step 1: Open Snippets File

Press Ctrl + Shift + P → search "Snippets: Configure User Snippets" → select javascriptreact (or javascriptreact.json).

Step 2: Add Custom React Snippet JSON

{
  "React Component with Tailwind": {
    "prefix": "rtw",
    "body": [
      "import React from 'react';",
      "",
      "const $1 = () => {",
      "  return (",
      "    <div className=\"p-4 max-w-sm mx-auto bg-white rounded-xl shadow-md flex items-center space-x-4\">",
      "      <h2 className=\"text-xl font-bold\">$1</h2>",
      "    </div>",
      "  );",
      "};",
      "",
      "export default $1;"
    ],
    "description": "Create React component pre-styled with Tailwind CSS"
  },
  "Custom Hook Template": {
    "prefix": "useCustom",
    "body": [
      "import { useState, useEffect } from 'react';",
      "",
      "export const use$1 = (initialValue) => {",
      "  const [value, setValue] = useState(initialValue);",
      "",
      "  useEffect(() => {",
      "    $2",
      "  }, [value]);",
      "",
      "  return [value, setValue];",
      "};"
    ],
    "description": "Custom React Hook Template"
  }
}

Now typing rtw or useCustom creates your personalized React templates instantly!


7. Pro VS Code Tips for React Developers

Tip 1: Auto-Import Components on Type

When you type <UserProfile /> in JSX, VS Code can automatically add import UserProfile from './UserProfile'; at the top of your file!

Ensure this is enabled in .vscode/settings.json:

{
  "javascript.suggest.autoImports": true,
  "typescript.suggest.autoImports": true
}

Tip 2: Instant Component Extraction

Select any JSX element → press Ctrl + . (or Cmd + . on Mac) → choose "Extract to component in module scope". VS Code will generate a new component for you automatically!

Tip 3: Go to Component Source (F12 / Ctrl + Click)

Hold Ctrl and click on any custom React component tag like <Navbar /> to jump straight to the source file where <Navbar> is defined.

Tip 4: Toggle JSX Comment Shortcut

Press Ctrl + / (or Cmd + /) inside JSX to automatically wrap selected lines with valid JSX comment syntax {/* comment */}.


Summary — Top React Shorthands Cheat Sheet

ShorthandResult / Code Template
rafceArrow Component + Export Default
rfceFunction Component + Export Default
usfconst [state, setState] = useState()
uefuseEffect(() => {}, [])
ucfconst value = useContext()
urfconst ref = useRef()
umfconst val = useMemo(() => fn, [deps])
ucbconst fn = useCallback(() => {}, [deps])
Ctrl + /Toggle {/* JSX Comment */}
Ctrl + .Quick Fix / Extract Component

📚 Read More ReactJS & Web Tutorials

Continue expanding your ReactJS knowledge with our guides:

Happy coding React! 🎉 Master these ReactJS shorthands to build UI components faster than ever!

← Back to react-js
Share: