Telegram Group & Telegram Channel
Async Transitions: обновление без блокировки

Transition API в React позволяет плавно обновлять состояние без блокировки UI.

Как использовать:

1. Импортируйте useTransition.
2. Создайте хук useTransition.
3. Оберните изменение состояния в startTransition.

Что происходит:

1. startTransition вызывает функцию асинхронно, позволяя отменить изменение.
2. Пока функция выполняется, isPending = true.
3. Когда функция завершается, isPending = false.

Пример:

function TabContainer() {
const [isPending, startTransition] = useTransition();
const [tab, setTab] = useState('about');

function selectTab(nextTab) {
startTransition(() => {
setTab(nextTab);
});
}

return (
<div>
<p>Current tab: {tab}</p>
<button onClick={() => selectTab('home')}>Home</button>
<button onClick={() => selectTab('about')}>About</button>
{isPending && <p>Loading...</p>}
</div>
);
}


👉 @sWebDev
👍4



tg-me.com/sWebDev/2753
Create:
Last Update:

Async Transitions: обновление без блокировки

Transition API в React позволяет плавно обновлять состояние без блокировки UI.

Как использовать:

1. Импортируйте useTransition.
2. Создайте хук useTransition.
3. Оберните изменение состояния в startTransition.

Что происходит:

1. startTransition вызывает функцию асинхронно, позволяя отменить изменение.
2. Пока функция выполняется, isPending = true.
3. Когда функция завершается, isPending = false.

Пример:

function TabContainer() {
const [isPending, startTransition] = useTransition();
const [tab, setTab] = useState('about');

function selectTab(nextTab) {
startTransition(() => {
setTab(nextTab);
});
}

return (
<div>
<p>Current tab: {tab}</p>
<button onClick={() => selectTab('home')}>Home</button>
<button onClick={() => selectTab('about')}>About</button>
{isPending && <p>Loading...</p>}
</div>
);
}


👉 @sWebDev

BY Frontender Libs - обзор библиотек JS / CSS




Share with your friend now:
tg-me.com/sWebDev/2753

View MORE
Open in Telegram


Frontender Libs обзор библиотек JS CSS 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.

To pay the bills, Mr. Durov is issuing investors $1 billion to $1.5 billion of company debt, with the promise of discounted equity if the company eventually goes public, the people briefed on the plans said. He has also announced plans to start selling ads in public Telegram channels as soon as later this year, as well as offering other premium services for businesses and users.

Frontender Libs обзор библиотек JS CSS from us


Telegram Frontender Libs - обзор библиотек JS / CSS
FROM USA