
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.
Await promises for React components
To install awaitx, use npm or yarn:
npm install awaitx
or
yarn add awaitx
awaitx provides a simple and intuitive way to handle promises in React components. It allows you to declaratively specify the loading, success, and error states of a promise using the <Await> component.
Before using awaitx:
export const HotPosts = () => {
const [posts, setPosts] = useState<Post[]>();
const [error, setError] = useState<unknown>();
const [fetchingPosts, setFetchingPosts] = useState(false);
useEffect(() => {
if (fetchingPosts || posts || error) return;
setFetchingPosts(true);
api
.listHotPosts({})
.then(setPosts)
.catch(setError)
.finally(() => setFetchingPosts(false));
}, [fetchingPosts, posts, error]);
return (
<>
{error && <h3>{String(error)}</h3>}
{posts && <PostList posts={posts} />}
{fetchingPosts && <>Loading posts...</>}
</>
);
};
After using awaitx:
export const HotPosts = () => (
<Await
source={() => api.listHotPosts({})}
then={(posts) => <PostList posts={posts} />}
fail={(error) => <h3>{String(error)}</h3>}
meanwhile={<>Loading posts...</>}
/>
);
The <Await> component takes the following props:
source: A function that returns a promise. This is the promise that will be awaited.dependencies: An array of dependencies for the useFuture hook, similar to the dependencies array in useEffect. It determines when the promise should be re-evaluated. If not provided, it is treated as an empty array to prevent excessive reevaluation.then: A render prop that receives the resolved value of the promise and returns the JSX to render when the promise is fulfilled.fail: A render prop that receives the error value if the promise is rejected and returns the JSX to render in case of an error.meanwhile: The JSX to render while the promise is pending.Using awaitx provides several benefits:
Contributions to awaitx are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
FAQs
Async TSX with less boilerplate
We found that awaitx 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.