2 ms·
Of course it's not functional code. Just as let result; for (const item of items) { result = await foo(item); if (result) { break;
by paulddraper 3y ago
Of course it's not functional code. Just as
let result;
for (const item of items) {
result = await foo(item);
if (result) {
break;
}
}
is not synchronous code. But you can write it very close to the mental model of synchronous programming.
The same is true of hooks. The code is not stateless, but you can write it very close to the mental model of stateless programming.
That is why -- despite them being optional -- hooks have become incredibly popular.