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: |

Add the logo from your device. Adjust the visible area of your image. Congratulations! Now your Telegram channel has a face Click “Save”.! The optimal dimension of the avatar on Telegram is 512px by 512px, and it’s recommended to use PNG format to deliver an unpixelated avatar. “[The defendant] could not shift his criminal liability,” Hui said. Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October. Matt Hussey, editorial director of NEAR Protocol (and former editor-in-chief of Decrypt) responded to the news of the Telegram group with “#meIRL.”
from us


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