Releases: msereniti/react-use-await
Releases · msereniti/react-use-await
v1.0.0
Initial release of fully rewritten library is here.
For now api looks like the following:
import { useAwait, AwaitBoundary } from 'react-use-await';
const getCurrency = async (id) => await fetch(`http://sereniti.tech/static/${id}.json`).then(res => res.json());
const CurrencyView = ({ id }) => {
const price = useAwait(getCurrency, id);
return <div>{id}: {price}</div>
}
export const App = () => {
return (
<AwaitBoundary loading="loading" ErrorView={({ error }) => error.message}>
<CurrencyView id="stonks" />
</AwaitBoundary>
)
}
The main difference from previous version is it now workings in O(useAwait hook usage count inside of one AwaitBoundary)
time that means O(1)
in most cases.