Тёмный

The mystery of React key: how to write performant lists 

Developer Way
Подписаться 12 тыс.
Просмотров 6 тыс.
50% 1

Опубликовано:

 

20 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 33   
@AbhishekPathak21
@AbhishekPathak21 Год назад
It's sad that deep and insightful videos like this don't show up in youtube search (came here from articles) and instead shows list of videos that all teach only basics.
@developerwaypatterns
@developerwaypatterns Год назад
Maybe it will change with the number of subscribers growing 🤞🏼
@newaroundhere
@newaroundhere 5 месяцев назад
Your videos are gold, mate 👏Very few creators go so deep into how React really works.
@elik3765
@elik3765 Год назад
Coming here from your articles. It's amazing how you merge a reader to a lower-level abstraction with very affordable tools, bit by bit. When I read your articles I sense that there should be a book named "You don't know React yet" ).
@developerwaypatterns
@developerwaypatterns Год назад
Haha, I'm working on the book like that right now, struggling with the title, and this one is brilliant! Can I use it if I don't come up with something better?
@elik3765
@elik3765 Год назад
@@developerwaypatterns I am afraid I wouldn't be the right person to ask for such a favor ). I was just coming from Kyle Simpson's bestseller series of "You don't know JS yet". It just seemed to me that you, two are using similar approach ).
@developerwaypatterns
@developerwaypatterns Год назад
@@elik3765 oops, taken then 😅Forgot about that one
@JustSkillGG
@JustSkillGG Год назад
Don't stop these videos. Your articles and these videos are great!
@指数函数没有极值
@指数函数没有极值 Год назад
This video built a new mental model for me
@mldddd
@mldddd Год назад
Very well made video! I think there is another use case for "using array index as key": - Array is dynamic (items CAN have local state & no React.memo) but you only ADD to Array (no re-order, no remove). That said, I would still recommend having unique ids as keys when possible, not index.
@developerwaypatterns
@developerwaypatterns Год назад
Yep, agree on both 🙂
@satejbidvai
@satejbidvai 11 месяцев назад
Your videos are a goldmine. Here, you dropped this: 👑
@mountakhabi
@mountakhabi Год назад
Thank you for this video ! Key also can be used for a Div, that you can force refender if needed
@developerwaypatterns
@developerwaypatterns Год назад
Yep, it can be used for any element
@HDdeiu
@HDdeiu Год назад
Thank you very much for your work! Your content is very good and very underrated by the community!
@sebabratakundu
@sebabratakundu Год назад
the only video you ever need!!
@metalyx1
@metalyx1 Год назад
That's a great explanations of React Keys!
@katsunoi
@katsunoi Год назад
excellent video
@loia5tqd001
@loia5tqd001 Год назад
Some awkward cases I met was after every re-render I see more elements than it should when there’re some duplicated keys. E.g array has 10 values but after first re-render it becomes 12, 14, 16,… because some keys are duplicated (not unique). That’s why when I’m not sure which field is unique from the external source, I’ll just use key={Math.random()} and fuck the performance because an unnoticeable bad performance is better than an obvious bug that 10 elements shown as 12.
@developerwaypatterns
@developerwaypatterns Год назад
In that case it's easier just to use array's index, it's also guaranteed to be unique. With Math.random the problem is not only bad performance, but also it's a source of bugs. If your components in the list are focusable or have internal state, they will reset it with every re-render because of Math.random(). It won't happen with array's index.
@ПетърТодоров-о7ф
Love these videos
@ParshwaChokshi
@ParshwaChokshi 9 месяцев назад
True Gem
@lovikuanyshev
@lovikuanyshev 10 месяцев назад
Excuse me, I didnt get an argument about using dynamic array (without local state and React.memo) How does it allow us to use index as a key? can you please answer it deeply, maybe Im missing something
@developerwaypatterns
@developerwaypatterns 10 месяцев назад
Heya! I'm not sure I understand the question, can you be a bit more specific? 🤔
@lovikuanyshev
@lovikuanyshev 10 месяцев назад
@@developerwaypatterns on 11:23 you say that Array can be dynamic (without local state or React.memo in items), you mean that you can use indexes as keys if items (components) are not wrapped in React.memo or not using local states inside, if I understood correctly. But what does stop us from using indexes as keys if items actually will have local state or will be wrapped in React.memo?
@developerwaypatterns
@developerwaypatterns 10 месяцев назад
Nothing stops us, it's just you'll see weird bugs if those items are added/removed/re-ordered: state will be preserved based on the arrays's index. Same with React.memo - it will just not work if the items are re-ordered/added/removed from the middle of the array. I had a video on Reconciliation that digs deeper into the reasons for the behaviour, if you want to understand more how all of this works: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-724nBX6jGRQ.html
@developer_01
@developer_01 Год назад
Thanks for such a clear and concise explanation of this topic. I recently found your blogs... all are top-notch. Thanks for sharing your knowledge.
@paungster
@paungster Год назад
👏👍
@Zloy_jid
@Zloy_jid 7 месяцев назад
like+comment+subscription =) Thanks for the content!
@jn740
@jn740 Год назад
Having a better intro soundtrack would be great.
@developer_01
@developer_01 Год назад
Hi, can you please help me in understanding what side-effects mean in react? When we say side-effects happen in the context of react component what does it mean. Does it mean it depends on other components or something change outside of its scope?
@developerwaypatterns
@developerwaypatterns Год назад
This might be helpful to understand those: react.dev/learn/synchronizing-with-effects
@developer_01
@developer_01 Год назад
@@developerwaypatterns Thanks
Далее
useCallback for re-renders: remove most of them
8:31
Refs in React: from access to DOM to imperative API
12:53
The Fastest Way to Modify a List in C# | Coding Demo
10:30
Why do We Need Keys in React?
7:47
Просмотров 11 тыс.
The Key to Understanding React: Why Keys Matter
6:50
React JS Lists and Keys | Learn ReactJS
32:54
Просмотров 37 тыс.
Fantastic closures and how to find them in React
19:04
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 810 тыс.
Why you should NEVER use index as key in React Lists
19:28
Preventing re-renders with React.memo
11:39
Просмотров 6 тыс.