Which React Hook Mistakes can cause re-renders, memory leaks and bugs? Must for React beginners

  Рет қаралды 3,722

frontend. no limits.

frontend. no limits.

Күн бұрын

Top 7 mistakes for React Hooks useState, useEffect, useReducer, useCallback, useMemo.
Examples with explanations and live fixes will help in understanding react hooks.
React interview questions might also raise discussions about these mistakes.
So this video will be definitely useful for beginner junior react developers.
More is yet to come - subscribe to watch more!
Timestamps:
00:00 Mistake 1 - useState - nextState based on current state
01:16 Mistake 2 - useState/useReducer - initial state recalculation on re-renders
03:36 Mistake 3 - useEffect - calling fetch/axios directly in React component
06:50 Mistake 4 - useEffect - not removing listeners/timers on unmount
10:00 Mistake 5 - Dependencies array - passing ever-new objects
11:13 Mistake 6 - useCallback - event handlers re-creation on re-renders
12:30 Mistake 7 - useMemo - not memoizing values derived from props
#reactjs #reacthooks #usestate #useeffect #usememo #usereducer #usecallback

Пікірлер: 8
@vladozhekhovskyi6071
@vladozhekhovskyi6071 2 ай бұрын
it is very useful. thank you!
@letok2871
@letok2871 2 ай бұрын
Super, good job!
@Mathes881
@Mathes881 2 ай бұрын
Mistake 3 is not a mistake, just using libraries for managing server state is preferable, such as rtk query or react query (tanstack query). Mistake 7 solution is only good when there is a heave computation, we shouldn't wrap everything with useMemo because we are just adding additional memory usage, so that const with computed value is perfectly fine and recommended.
@frontend_no_limits
@frontend_no_limits 2 ай бұрын
1. Separation of concerns aren’t broken in mistake 3? Do you really think that UI component is responsible for implementation details of dealing with the persistence layer? Libraries are just helpers and implementation details. They shouldn’t dictate (or be a reason) how to separate concerns. 2. Example was definitely simplified, but what is the reason to recompute some complex value when props for it remain the same? And we’re not talking about primitives only, by the way. It might be non-memoized computed object. What then will happen if we pass such no -memoized new object into dependencies array of useEffect for example?
@huzafaarshad973
@huzafaarshad973 Ай бұрын
in second mistak waht if the props changes ? does it call the initial function again ?
@frontend_no_limits
@frontend_no_limits Ай бұрын
no, the initializer function won't be called again
Why I avoid useEffect For API Calls and use React Query instead
17:45
MVVM vs. MVI - Understand the Difference Once and for All
18:40
Philipp Lackner
Рет қаралды 27 М.
Black Magic 🪄 by Petkit Pura Max #cat #cats
00:38
Sonyakisa8 TT
Рет қаралды 32 МЛН
ДЕНЬ РОЖДЕНИЯ БАБУШКИ #shorts
00:19
Паша Осадчий
Рет қаралды 6 МЛН
OMG 😨 Era o tênis dela 🤬
00:19
Polar em português
Рет қаралды 12 МЛН
You might not need useEffect() ...
21:45
Academind
Рет қаралды 145 М.
All useEffect Mistakes Every Junior React Developer Makes
22:23
Custom Hooks in React: caveats, re-renders, props, initial state
11:17
frontend. no limits.
Рет қаралды 148
Learn React Hooks: useCallback - Simply Explained!
17:15
Cosden Solutions
Рет қаралды 70 М.
React Hooks Crash Course (useMemo, useCallback and more).
31:49
developedbyed
Рет қаралды 80 М.
ALL React Hooks Explained in 12 Minutes
12:21
Code Bootcamp
Рет қаралды 59 М.
Rust's Alien Data Types 👽 Box, Rc, Arc
11:54
Code to the Moon
Рет қаралды 132 М.
Next JS forms with Shadcn UI (the EASY way)
28:00
WebDevEducation
Рет қаралды 32 М.
Обзор игрового компьютера Макса 2в1
23:34
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 13 МЛН
Apple watch hidden camera
0:34
_vector_
Рет қаралды 53 МЛН