← Back to React Course | Chapter 1: Environment Setup & Tooling | Lesson 10 of 10

React के लिए VS Code Setup

React के लिए अपना editor setup करना drawing शुरू करने से पहले अपने pencils sharpen करने जैसा है -- यह इसके बाद हर चीज़ को आसान बनाता है।

Recommended VS Code Extensions

React work के लिए, ES7+ React/Redux/React-Native snippets extension handy JSX shortcuts जोड़ता है, और built-in JavaScript/TypeScript support पहले से बिना extra setup के JSX syntax समझता है।

Note: snippets extension installed होने पर एक auto-generate function component template के लिए एक नई component file में rafce type करें।
Warning: कुछ older React snippet extensions default रूप से class-component boilerplate generate करती हैं -- उन्हें (या settings को) prefer करें जो function components generate करती हैं, जो modern default है।

उदाहरण: Installing the React Snippets Extension

bash
# Install from the terminal (VS Code's `code` command must be on PATH)
code --install-extension dsznajder.es7-react-js-snippets

# Or from VS Code: Ctrl+Shift+X (Cmd+Shift+X on Mac), search
# "ES7+ React/Redux/React-Native snippets", click Install

⚠️ Run this in your own terminal or Node.js environment.

Auto-Format on Save Enable करना

Prettier का VS Code extension install करना और 'Format on Save' enable करना हर बार जब आप file save करते हैं आपके JSX/JS को automatically एक consistent style में reformat करता है।

Note: Teammates के साथ consistent formatting rules share करने के लिए हर किसी की personal editor settings पर rely करने के बजाय एक project में एक .prettierrc file जोड़ें।
Warning: Save पर Auto-format उस code को silently fix कर सकता है जो आप mid-way type कर रहे थे अगर आप accidentally save कर दें -- इसके आदी होने तक occasional reformatting की उम्मीद करें।

उदाहरण: Setting Up Prettier and Format on Save

bash
$ code --install-extension esbenp.prettier-vscode

// .vscode/settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true
}

// .prettierrc
{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2
}

⚠️ Run this in your own terminal or Node.js environment.

Built-in Terminal Use करना

VS Code का integrated terminal (View > Terminal) आपको editor window छोड़े बिना npm run dev जैसे npm commands run करने देता है।

Note: एक dev server को एक pane में running रखते हुए दूसरे pane में दूसरे commands run करने के लिए terminal panel split करें।
Warning: एक dev server चलते समय integrated terminal panel बंद करना आमतौर पर उस server को भी रोक देता है।

उदाहरण: Opening the Terminal and Starting the Dev Server

bash
# Open the integrated terminal
# Windows/Linux: Ctrl + `
# Mac: Cmd + `

$ npm run dev
  VITE v5.0.0  ready in 320 ms
  ➜  Local:   http://localhost:5173/

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक ESLint extension install न करना, type करते समय helpful warnings miss करना।
  2. Prettier setup skip करना और inconsistent code formatting में end up होना।
  3. Auto-save enable न करना, testing करते समय lost preview updates की ओर ले जाना।
चैप्टर सारांश
  • VS Code React development के लिए सबसे popular editor है।
  • ESLint extension editor में directly code-quality issues surface करता है।
  • Prettier extension code को consistently auto-format करता है।
  • ES7+ React snippets जैसे extensions common component patterns लिखने की speed बढ़ाते हैं।
ब्राउज़र सपोर्ट

Applicable नहीं -- editor setup एक development-time concern है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.