
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-async-view
Advanced tools
Component handling isEmpty, isLoading and promise rejections for data loaded asynchronously.
Lightweight React component for handling data that can be fetched asynchronously. This kind of data can typically be in a loading, empty, ready or error state. Handling all of these states can result in code that is not very clean or readable. AsyncView component solves this issue. Works well with React Native too.
npm i react-async-view
With a promise returning an array (isLoading, isEmpty and error checks are done automatically).
<AsyncView
promise={this.booksPromise}
renderLoading={() => <div>Loading...</div>}
renderEmpty={() => <div>No books found</div>}
renderRejected={() => <div>Error loading books</div>}
>
{(books: Books) =>
books.map(book => (
<div>
<b>{book.name}</b>
Author: {book.author}
</div>
))
}
</AsyncView>
If books is null (or anything falseable) renderEmpty is used instead. You don't have to check if books is defined.
You can also use data props instead of promise. In this case you should provide isLoading and isError props too. Component still checks if data is empty, but isEmpty override is available.
Without AsyncView the code would look like something like this:
// componentWillMount()
this.setState({ isLoading: true });
fetchJson("http://example.com/books.json")
.then(books => {
this.setState({
isLoading: false,
books
});
})
.catch(error => {
this.setState({
isError: true,
isLoading: false,
error
});
});
// render()
const { books, isLoading, isError, error } = this.state;
if (isLoading) {
return <div>Loading...</div>;
} else if (!books) {
return <div>No books found</div>;
} else if (books.length > 0) {
return (
<Fragment>
books.map(book => (
<div>
<b>{book.name}</b>
Author: {book.author}
</div>
))
</Fragment>
);
}
FAQs
Component handling isEmpty, isLoading and promise rejections for data loaded asynchronously.
We found that react-async-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.