Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

All 17 React Best Practices

ByteGrad via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Learn 17 essential React best practices in this comprehensive video tutorial that covers critical development patterns and techniques to elevate your coding skills to a senior developer level. Master the fundamentals of avoiding hard-coded values and magic numbers by implementing proper constants management. Discover optimal folder structure organization strategies that scale with your project's growth. Understand when and how to create reusable components effectively while avoiding unnecessary markup and div elements. Explore the importance of separating layout styles from reusable components to maintain flexibility and reusability. Dive into TypeScript integration within React applications, learning where and why to implement type safety. Practice keeping components simple through children patterns and proper useState updater function usage. Learn to create separate event handler functions instead of directly using setter functions from useState for better code organization. Master proper prop naming conventions, especially when dealing with function props. Optimize performance using useMemo, useCallback, and React.memo() strategically. Understand when to use updater functions from useState and how to consolidate multiple states into single state objects. Implement the single source of truth principle by tracking selected or active items by ID rather than entire objects. Leverage URL state management for filters, pagination, and other stateful data instead of relying solely on useState. Keep useEffect hooks focused with one concern per effect for better maintainability. Explore modern alternatives to data fetching in useEffect for improved performance and user experience. Enhance overall application architecture through proper component organization, custom hooks, and utility functions.

Syllabus

00:00 Best practices = Senior dev
01:12 Sponsor
03:58 #1 Constants / Hard-coded values / Magic values
12:03 #2 Folder structure
16:02 #3 Components: when to create them
23:42 #4 Avoid unnecessary markup div's
27:28 #5 IMPORTANT: don't add layout styles to reusable component
33:30 #6 Use TypeScript why & where in React
37:07 #7 IMPORTANT: Keep components simple children pattern, updater function for useState
51:32 #8 IMPORTANT: Don't use setter function from useState, instead create a separate event handler function
55:43 #9 IMPORTANT: Naming props when prop is a function
01:02:42 #10 useMemo, useCallback & React.memo for performance
01:09:12 #11 When to use updater function from useState
01:11:32 #12 Use single state instead of multiple states
01:13:15 #13 IMPORTANT: one source of truth in programming. Keep track of a 'selected' or 'active' item by its id, NOT its whole object!
01:18:18 #14 IMPORTANT: use the URL for some state filters, pagination, etc., not useState
01:21:37 #15 Keep useEffect simple: one concern per useEffect
01:26:18 #16 IMPORTANT: instead of fetching data in useEffect, consider alternatives
01:33:12 #17 IMPORTANT: improve overall structure with components, custom hooks and utility functions
01:45:50 Outro

Taught by

ByteGrad

Reviews

Start your review of All 17 React Best Practices

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.