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
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:
- ⚛️ ReactJS Get Started Guide
- 🧩 Functional Component vs Class Component
- 🏆 ReactJS Tips and Tricks with Examples
- ⚡ VS Code HTML Shorthand (Emmet) Guide
- 🎨 VS Code CSS Shorthand (Emmet) Guide
- 📜 VS Code JavaScript Shorthand & Snippets Guide
1. Component Generation Shorthands
These are the most famous React snippets used by millions of frontend developers every day:
| Shorthand | Output / Expands To | Description |
|---|---|---|
rafce | Arrow Functional Component + Export Default | Most popular! Creates const Component = () => {} and exports default |
rfce | Regular Functional Component + Export Default | Creates function Component() {} and exports default |
rafc | Arrow Functional Component | Creates arrow component without export default |
rfc | Regular Functional Component | Creates regular function component without export default |
tsrafce | TypeScript Arrow Component | Arrow component with TypeScript interface |
tsrfce | TypeScript Function Component | Function 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:
| Shorthand | Expands To | Description |
|---|---|---|
usf or useState | const [state, setState] = useState(initialState) | useState Hook |
uef or useEffect | useEffect(() => { ... }, []) | useEffect Hook |
ucf or useContext | const value = useContext(MyContext) | useContext Hook |
urf or useRef | const refContainer = useRef(initialValue) | useRef Hook |
umf or useMemo | const memoizedValue = useMemo(() => compute(), [deps]) | useMemo Hook |
ucb or useCallback | const memoizedCallback = useCallback(() => {}, [deps]) | useCallback Hook |
ure or useReducer | const [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
classtoclassName!
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 Handler | Inline 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
| Shorthand | Result / Code Template |
|---|---|
rafce | Arrow Component + Export Default |
rfce | Function Component + Export Default |
usf | const [state, setState] = useState() |
uef | useEffect(() => {}, []) |
ucf | const value = useContext() |
urf | const ref = useRef() |
umf | const val = useMemo(() => fn, [deps]) |
ucb | const 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:
- ⚛️ ReactJS Get Started Guide
- 🧩 Functional Component vs Class Component & Props
- 🔄 ReactJS State Management (useState)
- 🏆 ReactJS Tips and Tricks with Examples
- 📜 VS Code JavaScript Shorthand & Snippets Guide
- ⚡ VS Code HTML Shorthand (Emmet) Guide
- 🎨 VS Code CSS Shorthand (Emmet) Guide
Happy coding React! 🎉 Master these ReactJS shorthands to build UI components faster than ever!