Create React App से App बनाना
npx create-react-app app-name
cd app-name
npm start
Create React App क्या Setup करता है
Create React App (CRA) एक command है जो एक ready-to-run React project generate करता है -- folder structure, एक build configuration, और एक dev server -- ताकि आपको एक bundler हाथ से configure न करना पड़े।
उदाहरण: What Create React App Sets Up
$ npx create-react-app my-app
Creating: my-app/src, my-app/public, my-app/package.json
Success! Your project is ready.
⚠️ Run this in your own terminal or Node.js environment.
Dev Server Start करना
एक CRA project के अंदर, npm start run करना एक local development server launch करता है (आमतौर पर localhost:3000 पर) जो आपके कोई file save करने पर automatically page reload करता है।
उदाहरण: Starting the Dev Server
$ npm start
Compiled successfully!
Local: http://localhost:3000
⚠️ Run this in your own terminal or Node.js environment.
CRA Folder Structure
एक fresh CRA project में आपके components के लिए एक src/ folder है (App.js और index.js से शुरू), static files जैसे HTML shell और favicon के लिए एक public/ folder, और dependencies list करने वाला package.json।
उदाहरण: The CRA Folder Structure
$ ls -R my-app
my-app:
node_modules package.json public README.md src
my-app/public:
favicon.ico index.html manifest.json robots.txt
my-app/src:
App.css App.js App.test.js index.css index.js logo.svg
⚠️ Run this in your own terminal or Node.js environment.
- नए projects के लिए Create React App उपयोग करना भले ही यह अब Vite के favor में actively recommend नहीं किया जाता।
npm startऔरnpm run buildअसल में क्या करते हैं यह न समझना।- Generated config files को manually edit करना यह realize किए बिना कि वे updates पर reset हो सकती हैं।
- Create React App (CRA) एक command से एक पूरा React project scaffold करता है।
- यह Webpack, Babel, और दूसरी tooling bundle करता है ताकि आपको उन्हें खुद configure न करना पड़े।
npm startएक local dev server run करता है;npm run buildएक production bundle बनाता है।- CRA अब legacy माना जाता है -- Vite आज ज़्यादा commonly recommended alternative है।
Generated app खुद default रूप से सभी modern evergreen browsers को support करता है; CRA एक build tool है, कोई runtime concern नहीं।
Chapter Quiz — Complete all 10 topics to unlock
0/10 topics done
Complete these topics first: