Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/danue1/use-async-effekt


https://github.com/danue1/use-async-effekt

Last synced: 10 days ago
JSON representation

Awesome Lists containing this project

README

        

# useAsyncEffekt

## Example

```tsx
import { useAsyncEffect, isMounted, unwrap } from "use-async-effekt";

const App = () => {
const [user, setUser] = useState(null);

useAsyncEffect(async resolve => {
const user = await resolve(loadUser());
if (isMounted(user)) {
setUser(unwrap(user));
}
}, []);

if (user === null) {
return <>LOADING>;
}

return <>{user.displayName}>;
};
```

## Installation

```cmd
# npm
npm i use-async-effekt

# yarn
yarn add use-async-effekt
```