Facebook Pixel
Searching...
فارسی
EnglishEnglish
EspañolSpanish
简体中文Chinese
FrançaisFrench
DeutschGerman
日本語Japanese
PortuguêsPortuguese
ItalianoItalian
한국어Korean
РусскийRussian
NederlandsDutch
العربيةArabic
PolskiPolish
हिन्दीHindi
Tiếng ViệtVietnamese
SvenskaSwedish
ΕλληνικάGreek
TürkçeTurkish
ไทยThai
ČeštinaCzech
RomânăRomanian
MagyarHungarian
УкраїнськаUkrainian
Bahasa IndonesiaIndonesian
DanskDanish
SuomiFinnish
БългарскиBulgarian
עבריתHebrew
NorskNorwegian
HrvatskiCroatian
CatalàCatalan
SlovenčinaSlovak
LietuviųLithuanian
SlovenščinaSlovenian
СрпскиSerbian
EestiEstonian
LatviešuLatvian
فارسیPersian
മലയാളംMalayalam
தமிழ்Tamil
اردوUrdu
The Road to React

The Road to React

توسط Robin Wieruch 2017 410 صفحات
4.22
500+ امتیازها
گوش دادن
Listen to Summary

نکات کلیدی

1. اصول اولیه React: کامپوننت‌ها، JSX و مدیریت وضعیت

کامپوننت‌ها پایه و اساس هر برنامه React هستند.

بلوک‌های سازنده React. کامپوننت‌ها هسته اصلی برنامه‌های React هستند که به توسعه‌دهندگان امکان می‌دهند عناصر رابط کاربری قابل استفاده مجدد و ماژولار ایجاد کنند. JSX، یک افزونه نحوی برای جاوااسکریپت، امکان ادغام بی‌وقفه کد شبیه HTML را در جاوااسکریپت فراهم می‌کند و توصیف ساختار کامپوننت‌های React را آسان‌تر می‌سازد.

وضعیت و props. سیستم مدیریت وضعیت React، عمدتاً از طریق hook useState، به کامپوننت‌ها اجازه می‌دهد داده‌های خود را نگه‌داری و به‌روزرسانی کنند. از سوی دیگر، props انتقال داده‌ها و توابع بین کامپوننت‌ها را تسهیل می‌کند و جریان داده یک‌طرفه را ممکن می‌سازد. این ترکیب از وضعیت و props ستون فقرات مدل برنامه‌نویسی اعلامی React را تشکیل می‌دهد، جایی که توسعه‌دهندگان وضعیت رابط کاربری مطلوب را توصیف می‌کنند و React به‌طور کارآمد DOM را برای تطابق به‌روزرسانی می‌کند.

2. مدیریت داده‌های ناهمگام و اثرات جانبی در React

Hook useEffect در React هر بار که آرایه وابستگی آن تغییر می‌کند، یک تابع یادآوری شده ایجاد می‌کند.

مدیریت اثرات جانبی. hook useEffect برای مدیریت اثرات جانبی در کامپوننت‌های React، مانند واکشی داده، اشتراک‌ها یا تغییر دستی DOM بسیار مهم است. این امکان را به توسعه‌دهندگان می‌دهد تا این عملیات را پس از رندر شدن کامپوننت انجام دهند و تجربه کاربری روان و جلوگیری از رندرهای غیرضروری را تضمین کنند.

عملیات ناهمگام. هنگام کار با عملیات ناهمگام مانند فراخوانی‌های API، React الگوهایی برای مدیریت وضعیت بارگذاری، مدیریت خطا و به‌روزرسانی داده‌ها ارائه می‌دهد. تکنیک‌هایی مانند رندر شرطی بر اساس وضعیت بارگذاری/خطا و استفاده از نحو async/await در callback‌های useEffect به ایجاد مکانیزم‌های واکشی داده قوی کمک می‌کنند.

  • جنبه‌های کلیدی مدیریت داده‌های ناهمگام:
    • تنظیم وضعیت‌های بارگذاری و خطا
    • استفاده از async/await برای کد ناهمگام تمیزتر
    • پیاده‌سازی مرزهای خطا برای مدیریت خطای باوقار
    • لغو درخواست‌های در حال انجام هنگام unmount شدن کامپوننت‌ها

3. کامپوننت‌های کنترل‌شده و فرم‌ها در React

فرم‌ها در JSX React تفاوت زیادی با HTML ندارند.

مدیریت فرم. رویکرد React به مدیریت فرم حول مفهوم کامپوننت‌های کنترل‌شده می‌چرخد. در این الگو، عناصر فرم مانند فیلدهای ورودی، چک‌باکس‌ها و منوهای کشویی توسط وضعیت React کنترل می‌شوند و رفتار فرم قابل پیش‌بینی‌تر و قابل مدیریت‌تری را فراهم می‌کنند.

مدیریت رویداد. React یک سیستم رویداد مصنوعی ارائه می‌دهد که سیستم رویداد بومی مرورگر را پوشش می‌دهد و یک رابط کاربری سازگار در مرورگرهای مختلف ارائه می‌دهد. این سیستم به توسعه‌دهندگان اجازه می‌دهد به‌راحتی مدیریت‌کننده‌های رویداد را به عناصر فرم متصل کنند و تعاملات کاربر را مدیریت کنند.

  • جنبه‌های کلیدی مدیریت فرم در React:
    • استفاده از hook useState برای مدیریت وضعیت فرم
    • پیاده‌سازی مدیریت‌کننده‌های onChange برای به‌روزرسانی وضعیت
    • جلوگیری از رفتار پیش‌فرض ارسال فرم
    • اعتبارسنجی ورودی‌های فرم و نمایش پیام‌های خطا

4. تکنیک‌های بهینه‌سازی عملکرد برای برنامه‌های React

API memo در React بررسی می‌کند که آیا props یک کامپوننت تغییر کرده است یا خیر.

جلوگیری از رندرهای غیرضروری. رفتار پیش‌فرض React برای رندر مجدد کامپوننت‌های فرزند هنگام به‌روزرسانی کامپوننت والد گاهی اوقات می‌تواند منجر به مشکلات عملکردی شود. کامپوننت بالاتر مرتبه memo و hook useMemo به توسعه‌دهندگان اجازه می‌دهند با یادآوری کامپوننت‌ها و مقادیر، بهینه‌سازی رندر را انجام دهند.

تقسیم کد و بارگذاری تنبل. با رشد برنامه‌های React، پیاده‌سازی تکنیک‌های تقسیم کد بسیار مهم می‌شود. کامپوننت‌های React.lazy و Suspense به توسعه‌دهندگان اجازه می‌دهند کد خود را به قطعات کوچکتر تقسیم کنند و آن‌ها را بر اساس نیاز بارگذاری کنند، که به‌طور قابل توجهی زمان بارگذاری اولیه و عملکرد کلی برنامه را بهبود می‌بخشد.

  • تکنیک‌های کلیدی بهینه‌سازی عملکرد:
    • استفاده از React.memo برای کامپوننت‌های تابعی
    • پیاده‌سازی useMemo برای محاسبات پرهزینه
    • استفاده از useCallback برای یادآوری توابع callback
    • استفاده از React.lazy و Suspense برای تقسیم کد
    • پیاده‌سازی مجازی‌سازی برای لیست‌های طولانی

5. الگوهای پیشرفته React: هوک‌های سفارشی و یادآوری

هوک‌های سفارشی منطق قابل استفاده مجدد را به روشی که به‌راحتی بین کامپوننت‌ها به اشتراک گذاشته می‌شود، محصور می‌کنند.

ایجاد هوک‌های سفارشی. هوک‌های سفارشی به توسعه‌دهندگان اجازه می‌دهند منطق کامپوننت را به توابع قابل استفاده مجدد استخراج کنند و استفاده مجدد از کد و جداسازی نگرانی‌ها را ترویج دهند. آن‌ها از همان قوانین هوک‌های داخلی React پیروی می‌کنند و می‌توانند از هوک‌های دیگر در پیاده‌سازی خود استفاده کنند.

تکنیک‌های یادآوری. یادآوری یک تکنیک بهینه‌سازی قدرتمند در React است که برای ذخیره نتایج محاسبات پرهزینه یا جلوگیری از رندرهای غیرضروری استفاده می‌شود. هوک‌های useMemo و useCallback ابزارهای اصلی برای پیاده‌سازی یادآوری در کامپوننت‌های تابعی هستند.

  • مزایای هوک‌های سفارشی و یادآوری:
    • بهبود سازماندهی و استفاده مجدد از کد
    • بهبود عملکرد از طریق ذخیره‌سازی
    • جداسازی بهتر نگرانی‌ها در کامپوننت‌ها
    • تست آسان‌تر منطق پیچیده

6. تست برنامه‌های React: تست واحد، یکپارچه‌سازی و عکس‌برداری

کتابخانه تست React به یک فلسفه اصلی پایبند است: به‌جای تست جزئیات پیاده‌سازی کامپوننت‌های React، نحوه تعامل کاربران با برنامه و اینکه آیا به‌درستی کار می‌کند را تست می‌کند.

فلسفه تست. جامعه React بر تست رفتار کاربر به‌جای جزئیات پیاده‌سازی تأکید دارد. این رویکرد منجر به تست‌های قوی‌تری می‌شود که کمتر به دلیل بازسازی داخلی شکسته می‌شوند.

ابزارها و تکنیک‌های تست. برنامه‌های React می‌توانند با استفاده از ترکیبی از تست‌های واحد برای توابع و کامپوننت‌های فردی، تست‌های یکپارچه‌سازی برای تعاملات کامپوننت و تست‌های عکس‌برداری برای شناسایی تغییرات غیرمنتظره رابط کاربری تست شوند. کتابخانه‌های تست محبوب شامل Jest برای اجرای تست و کتابخانه Assertion و React Testing Library برای رندر کامپوننت‌ها و شبیه‌سازی تعاملات کاربر هستند.

  • جنبه‌های کلیدی تست React:
    • نوشتن تست‌های واحد برای کامپوننت‌ها و توابع فردی
    • ایجاد تست‌های یکپارچه‌سازی برای تأیید تعاملات کامپوننت
    • استفاده از تست عکس‌برداری برای شناسایی تغییرات ناخواسته رابط کاربری
    • شبیه‌سازی فراخوانی‌های API و وابستگی‌های خارجی دیگر
    • پیاده‌سازی یکپارچه‌سازی مداوم برای تست خودکار

7. ساختاردهی و مقیاس‌پذیری پروژه‌های React

هیچ راه درست برای ساختار پوشه/فایل وجود ندارد.

سازماندهی پروژه. با رشد پروژه‌های React، سازماندهی مناسب برای نگهداری و مقیاس‌پذیری بسیار مهم می‌شود. در حالی که هیچ رویکرد یکسانی برای همه وجود ندارد، الگوهای رایج شامل سازماندهی بر اساس ویژگی، بر اساس نوع (کامپوننت‌ها، هوک‌ها، ابزارها) یا ترکیبی از هر دو است.

معماری ماژولار. پیاده‌سازی معماری ماژولار به مدیریت پیچیدگی با رشد پروژه کمک می‌کند. این شامل ایجاد کامپوننت‌های قابل استفاده مجدد، جداسازی نگرانی‌ها و ایجاد رابط‌های واضح بین بخش‌های مختلف برنامه است.

  • بهترین شیوه‌ها برای ساختاردهی پروژه‌های React:
    • پیاده‌سازی یک کنوانسیون نام‌گذاری سازگار
    • ایجاد جداسازی واضح بین کامپوننت‌های نمایشی و کانتینر
    • استفاده از فایل‌های index برای واردات تمیزتر
    • پیاده‌سازی بارگذاری تنبل برای بهبود عملکرد
    • استفاده از TypeScript برای بهبود ایمنی نوع و تجربه توسعه‌دهنده

آخرین به‌روزرسانی::

FAQ

What's "The Road to React" about?

  • Comprehensive Guide: "The Road to React" by Robin Wieruch is a comprehensive guide to learning React.js, a popular JavaScript library for building user interfaces.
  • Step-by-Step Learning: The book takes a step-by-step approach, starting with the fundamentals of React and gradually introducing more advanced concepts and features.
  • Practical Application: It emphasizes building a practical application in pure React, covering everything from project setup to deployment.
  • Iterative Learning: Each chapter includes exercises and additional reading to reinforce learning and provide a deeper understanding of React.

Why should I read "The Road to React"?

  • Beginner-Friendly: The book is designed for JavaScript beginners and veterans alike, making it accessible to a wide range of readers.
  • Hands-On Approach: It offers a hands-on approach to learning React, encouraging readers to code along and experiment with the examples.
  • Real-World Application: By the end of the book, readers will have the skills to develop their own React applications, incorporating features like pagination and advanced UI interactions.
  • Continuous Updates: The book is self-published, allowing for prompt updates to keep the material current with the latest React developments.

What are the key takeaways of "The Road to React"?

  • Core Principles: Readers will learn the core principles of React, including components, state, and props.
  • Component Hierarchies: The book covers how to build and manage component hierarchies in React applications.
  • State Management: It delves into state management, including the use of hooks like useState and useReducer.
  • Advanced Features: Readers will explore advanced features such as custom hooks, side-effects, and performance optimizations.

What are the best quotes from "The Road to React" and what do they mean?

  • "React continues to reinvent itself": This highlights React's adaptability and its influence on the evolution of other frameworks.
  • "Learn the fundamentals, learn how to connect to an API": Emphasizes the importance of mastering the basics and practical application in real-world scenarios.
  • "React is my indispensable daily companion": Reflects the author's deep reliance on React for productivity in web development projects.
  • "The book clarifies general concepts, patterns, and best practices": Underlines the book's focus on providing a clear understanding of React's core concepts and best practices.

How does "The Road to React" approach teaching React?

  • Pragmatic and Detail-Oriented: The book balances pragmatism with detailed explanations, providing the tools needed to get the job done while ensuring a deep understanding of React.
  • Interactive Exercises: Each chapter includes exercises to reinforce learning and encourage experimentation with the code.
  • Iterative Learning Process: The Lean Publishing process allows for continuous updates and reader feedback, ensuring the material remains relevant and effective.
  • Focus on Real-World Application: The book guides readers through building a practical application, emphasizing real-world use cases and best practices.

What is the significance of components in React according to "The Road to React"?

  • Foundation of React: Components are the foundation of every React application, encapsulating functionalities and contributing to the overall architecture.
  • Component Hierarchies: The book explains how React applications consist of hierarchical components, with a root component and various child and sibling components.
  • Reusability and Maintainability: Extracting components promotes reusability and maintainability, making the codebase more organized and scalable.
  • Component Composition: Readers learn about component composition, allowing for flexible and dynamic UI construction.

How does "The Road to React" explain state management?

  • useState Hook: The book introduces the useState hook for managing stateful values that change over time, triggering re-renders when updated.
  • useReducer Hook: It covers the useReducer hook for more complex state management, especially when multiple stateful values are interdependent.
  • Lifting State: Readers learn about lifting state to a common ancestor component to share and manage state across multiple components.
  • Avoiding Impossible States: The book emphasizes the importance of avoiding impossible states by consolidating related states into a single reducer.

What advanced features of React are covered in "The Road to React"?

  • Custom Hooks: The book explores creating custom hooks to encapsulate non-trivial logic and promote code reuse.
  • Side-Effects with useEffect: It covers the useEffect hook for handling side-effects, such as data fetching and interacting with third-party APIs.
  • Performance Optimizations: Readers learn about performance optimizations using memoization techniques like useMemo and useCallback.
  • Conditional Rendering: The book explains conditional rendering techniques to dynamically display content based on state or props.

How does "The Road to React" address styling in React applications?

  • CSS in React: The book starts with common CSS techniques for styling React applications, using className attributes and CSS files.
  • CSS Modules: It introduces CSS Modules for scoped styling, allowing for more modular and maintainable CSS.
  • Styled Components: Readers learn about Styled Components, a popular CSS-in-JS approach for defining styles directly within JavaScript files.
  • SVG Integration: The book covers integrating SVGs for icons and logos, enhancing the visual appeal of React applications.

What testing strategies are recommended in "The Road to React"?

  • Unit Testing: The book emphasizes unit testing for isolated functions and components, using Vitest and React Testing Library.
  • Integration Testing: It covers integration testing to ensure that components work together as expected, simulating user interactions.
  • Snapshot Testing: Readers learn about snapshot testing to capture and compare component output over time.
  • Testing Pyramid: The book introduces the testing pyramid, highlighting the importance of balancing unit, integration, and end-to-end tests.

How does "The Road to React" guide project structure and organization?

  • Component Separation: The book recommends separating components into individual files for better organization and scalability.
  • Folder Structure: It discusses various folder structures, including technical-oriented and domain-oriented approaches.
  • Code Splitting: Readers learn about code splitting to improve application performance and maintainability.
  • Reusability and Maintainability: The book emphasizes the importance of structuring code for reusability and maintainability, especially in larger projects.

What deployment strategies are covered in "The Road to React"?

  • Build Process: The book explains the build process for optimizing and packaging React applications for production.
  • Firebase Hosting: It provides a step-by-step guide for deploying React applications using Firebase Hosting.
  • Local Server Preview: Readers learn how to preview their production-ready applications using a local server before deployment.
  • Alternative Hosting Providers: The book encourages exploring other hosting providers and deployment strategies for React applications.

نقد و بررسی

4.22 از 5
میانگین از 500+ امتیازات از Goodreads و Amazon.

کتاب مسیر به ری‌اکت به طور گسترده‌ای نقدهای مثبتی دریافت کرده است و به خاطر وضوح، رویکرد عملی و پوشش جامع مبانی ری‌اکت مورد تحسین قرار گرفته است. خوانندگان از توضیحات گام به گام، ادغام ES6 و پروژه‌های عملی آن قدردانی می‌کنند. این کتاب برای مبتدیان و کسانی که تجربه‌ای در ری‌اکت دارند توصیه می‌شود. برخی از منتقدان به مختصر بودن آن و عدم پوشش موضوعات پیشرفته اشاره می‌کنند. سبک نگارش نویسنده و منابع اضافی به شدت مورد توجه قرار گرفته است. بیشتر خوانندگان آن را مقدمه‌ای عالی برای ری‌اکت می‌دانند، اگرچه برخی خواهان پوشش عمیق‌تر در برخی زمینه‌ها هستند.

درباره نویسنده

رابین ویروخ یک مهندس نرم‌افزار و فریلنسر آلمانی مستقر در برلین است. او در برنامه‌های تک‌صفحه‌ای با استفاده از فریم‌ورک‌های جاوااسکریپت مانند امبر، انگولار و ری‌اکت تخصص دارد. ویروخ به آموزش و به اشتراک‌گذاری دانش خود از طریق وبلاگش متعهد است و همواره در تلاش برای یادگیری و بهبود مهارت‌های خود است. به عنوان یک توسعه‌دهنده تمام‌وقت جاوااسکریپت، او تجربه گسترده‌ای در فناوری‌های مدرن توسعه وب کسب کرده است. علاقه او به آموزش و تعهدش به به‌روز ماندن در زمینه به سرعت در حال تحول توسعه وب، او را به یک چهره محترم در جامعه ری‌اکت تبدیل کرده است.

0:00
-0:00
1x
Dan
Andrew
Michelle
Lauren
Select Speed
1.0×
+
200 words per minute
Home
Library
Get App
Create a free account to unlock:
Requests: Request new book summaries
Bookmarks: Save your favorite books
History: Revisit books later
Recommendations: Get personalized suggestions
Ratings: Rate books & see your ratings
Try Full Access for 7 Days
Listen, bookmark, and more
Compare Features Free Pro
📖 Read Summaries
All summaries are free to read in 40 languages
🎧 Listen to Summaries
Listen to unlimited summaries in 40 languages
❤️ Unlimited Bookmarks
Free users are limited to 10
📜 Unlimited History
Free users are limited to 10
Risk-Free Timeline
Today: Get Instant Access
Listen to full summaries of 73,530 books. That's 12,000+ hours of audio!
Day 4: Trial Reminder
We'll send you a notification that your trial is ending soon.
Day 7: Your subscription begins
You'll be charged on Apr 9,
cancel anytime before.
Consume 2.8x More Books
2.8x more books Listening Reading
Our users love us
100,000+ readers
"...I can 10x the number of books I can read..."
"...exceptionally accurate, engaging, and beautifully presented..."
"...better than any amazon review when I'm making a book-buying decision..."
Save 62%
Yearly
$119.88 $44.99/year
$3.75/mo
Monthly
$9.99/mo
Try Free & Unlock
7 days free, then $44.99/year. Cancel anytime.
Scanner
Find a barcode to scan

Settings
General
Widget
Appearance
Loading...
Black Friday Sale 🎉
$20 off Lifetime Access
$79.99 $59.99
Upgrade Now →