Telegram Group & Telegram Channel
🧩 Фишка: оптимизация ререндеров в React через Object.freeze

Если в стейте компонента хранятся вложенные объекты, React не сможет понять, что они не изменились, даже если вы не меняли их вручную. Это может привести к лишним ререндерам.

📌 Решение: используйте Object.freeze() для вложенных структур, чтобы избежать случайных мутаций и упростить сравнение.


const initialFilters = Object.freeze({
category: 'all',
priceRange: [0, 100],
});

const [filters, setFilters] = useState(initialFilters);


⚠️ Замороженный объект нельзя мутировать — это делает поведение более предсказуемым.

💡 Также freeze улучшает производительность при использовании React.memo или useMemo, так как ссылки на вложенные структуры остаются стабильными.

👀 Подходит для конфигов, словарей, фильтров и других редко изменяемых объектов.

✍️ @React_lib



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

🧩 Фишка: оптимизация ререндеров в React через Object.freeze

Если в стейте компонента хранятся вложенные объекты, React не сможет понять, что они не изменились, даже если вы не меняли их вручную. Это может привести к лишним ререндерам.

📌 Решение: используйте Object.freeze() для вложенных структур, чтобы избежать случайных мутаций и упростить сравнение.


const initialFilters = Object.freeze({
category: 'all',
priceRange: [0, 100],
});

const [filters, setFilters] = useState(initialFilters);


⚠️ Замороженный объект нельзя мутировать — это делает поведение более предсказуемым.

💡 Также freeze улучшает производительность при использовании React.memo или useMemo, так как ссылки на вложенные структуры остаются стабильными.

👀 Подходит для конфигов, словарей, фильтров и других редко изменяемых объектов.

✍️ @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/669

View MORE
Open in Telegram


telegram Telegram | DID YOU KNOW?

Date: |

Dump Scam in Leaked Telegram Chat

A leaked Telegram discussion by 50 so-called crypto influencers has exposed the extraordinary steps they take in order to profit on the back off unsuspecting defi investors. According to a leaked screenshot of the chat, an elaborate plan to defraud defi investors using the worthless “$Few” tokens had been hatched. $Few tokens would be airdropped to some of the influencers who in turn promoted these to unsuspecting followers on Twitter.

Telegram auto-delete message, expiring invites, and more

elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.

telegram from vn


Telegram React
FROM USA