Telegram Group & Telegram Channel
🔍 Чекни скрытые баги в React: неправильное использование ключей в списках

Если ты рендеришь список компонентов и используешь index в качестве key, будь осторожен — это может привести к непредсказуемым багам UI.

📉 Что может пойти не так:
- Компоненты не будут корректно обновляться при изменении порядка;
- Сохранённое состояние внутри компонентов (например, в инпутах) будет сбиваться;
- Возрастает шанс багов при анимациях и переходах.

📌 Плохо:

{items.map((item, index) => (
<Card key={index} data={item} />
))}


Хорошо:

{items.map((item) => (
<Card key={item.id} data={item} />
))}


🎯 Совет: используй id, UUID или стабильные ключи из данных. Если данных нет — скорее всего, нужно пересмотреть архитектуру.

Подробный разбор от React team:
https://react.dev/learn/rendering-lists#choosing-the-key

✍️ @React_lib



tg-me.com/React_lib/670
Create:
Last Update:

🔍 Чекни скрытые баги в React: неправильное использование ключей в списках

Если ты рендеришь список компонентов и используешь index в качестве key, будь осторожен — это может привести к непредсказуемым багам UI.

📉 Что может пойти не так:
- Компоненты не будут корректно обновляться при изменении порядка;
- Сохранённое состояние внутри компонентов (например, в инпутах) будет сбиваться;
- Возрастает шанс багов при анимациях и переходах.

📌 Плохо:


{items.map((item, index) => (
<Card key={index} data={item} />
))}


Хорошо:

{items.map((item) => (
<Card key={item.id} data={item} />
))}


🎯 Совет: используй id, UUID или стабильные ключи из данных. Если данных нет — скорее всего, нужно пересмотреть архитектуру.

Подробный разбор от React team:
https://react.dev/learn/rendering-lists#choosing-the-key

✍️ @React_lib

BY React


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/React_lib/670

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

The STAR Market, as is implied by the name, is heavily geared toward smaller innovative tech companies, in particular those engaged in strategically important fields, such as biopharmaceuticals, 5G technology, semiconductors, and new energy. The STAR Market currently has 340 listed securities. The STAR Market is seen as important for China’s high-tech and emerging industries, providing a space for smaller companies to raise capital in China. This is especially significant for technology companies that may be viewed with suspicion on overseas stock exchanges.

The messaging service and social-media platform owes creditors roughly $700 million by the end of April, according to people briefed on the company’s plans and loan documents viewed by The Wall Street Journal. At the same time, Telegram Group Inc. must cover rising equipment and bandwidth expenses because of its rapid growth, despite going years without attempting to generate revenue.

telegram from br


Telegram React
FROM USA