FRONTEND_1 Telegram 3965
🚀 Как ускорить рендеринг списков в React?

Когда работаешь с большими списками, правильная оптимизация критична. Один из лучших способов — использовать React.memo и мемоизировать элементы списка!

Вот паттерн:


const ListItem = React.memo(({ item }: { item: ItemType }) => {
return <div>{item.name}</div>;
});

function List({ items }: { items: ItemType[] }) {
return (
<div>
{items.map((item) => (
<ListItem key={item.id} item={item} />
))}
</div>
);
}


Что происходит:
- ListItem будет перерисован только если item изменился.
- key помогает React правильно отслеживать изменения.

🔗 Если список ОЧЕНЬ длинный — подключи react-window или react-virtualized для виртуализации. Это даст огромный прирост производительности.


👉 @frontend_1
👍3



tgoop.com/frontend_1/3965
Create:
Last Update:

🚀 Как ускорить рендеринг списков в React?

Когда работаешь с большими списками, правильная оптимизация критична. Один из лучших способов — использовать React.memo и мемоизировать элементы списка!

Вот паттерн:


const ListItem = React.memo(({ item }: { item: ItemType }) => {
return <div>{item.name}</div>;
});

function List({ items }: { items: ItemType[] }) {
return (
<div>
{items.map((item) => (
<ListItem key={item.id} item={item} />
))}
</div>
);
}


Что происходит:
- ListItem будет перерисован только если item изменился.
- key помогает React правильно отслеживать изменения.

🔗 Если список ОЧЕНЬ длинный — подключи react-window или react-virtualized для виртуализации. Это даст огромный прирост производительности.


👉 @frontend_1

BY Frontend разработчик




Share with your friend now:
tgoop.com/frontend_1/3965

View MORE
Open in Telegram


Telegram News

Date: |

The best encrypted messaging apps Telegram is a leading cloud-based instant messages platform. It became popular in recent years for its privacy, speed, voice and video quality, and other unmatched features over its main competitor Whatsapp. In the “Bear Market Screaming Therapy Group” on Telegram, members are only allowed to post voice notes of themselves screaming. Anything else will result in an instant ban from the group, which currently has about 75 members. "Doxxing content is forbidden on Telegram and our moderators routinely remove such content from around the world," said a spokesman for the messaging app, Remi Vaughn. Deputy District Judge Peter Hui sentenced computer technician Ng Man-ho on Thursday, a month after the 27-year-old, who ran a Telegram group called SUCK Channel, was found guilty of seven charges of conspiring to incite others to commit illegal acts during the 2019 extradition bill protests and subsequent months.
from us


Telegram Frontend разработчик
FROM American