New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-client-async

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-client-async

React tools for use async in client side

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-99.15%
Maintainers
0
Weekly downloads
 
Created
Source

⚛️⏳ React Async for Client

  • Demo: shao.fun/react-client-async
  • Repo: github.com/hk-shao/react-client-async

Previously, async component were only supported on the server (Next.js). With this package, you can now easily use it on the client side as well.

Install

npm i react-client-async

useAsync Hook

You can use the useAsync hook to create a task.

console.log(useAsync(fn, args, options));

Async Component

You can use the Async component to render an async component.

<Async
  $fc={fc} // may be an async function component
  $waiting={waiting} // waiting component
  $fallback={fallback} // fallback component
  {...props} // props for the function component
/>

Demo of Recursive Async Component

A component can be used with memo and async together!

const Rec: AsyncFC<{ n: number; }> = memo(
  async ({ [$signal]: signal, n }) =>
    n <= 0 ? (
      <> {/* break the recursion */}
        <div>0</div>
      </>
    ) : (
      <> {/* delay and recursion */}
        {await delayWithSignal(99, signal)}
        {n}<Async $fc={Rec} n={n - 1} />{n}
      </>
    ),
);

What is Next?

  • useAsyncIterable hook
  • Iterable async component
async function* IterableComponent() {
  yield* OtherIterableComponent();
  yield  await component1();
  yield  await component2();
  yield  <div>...</div>;
}

Looking forward to your feedback or contribution! 🚀🚀🚀

Development

Install

  • Install bun runtime: npm install -g bun
  • Install dependencies: bun install

Run & Build

  • Run demo: bun dev
  • Build demo: bun run build:app
  • Build package: bun run build:lib

Deploy

  • Deploy demo to github pages: bun run deploy
  • Publish the package to npm: bun publish

Keywords

FAQs

Package last updated on 24 Jan 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc