Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danue1/use-async-effekt
https://github.com/danue1/use-async-effekt
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/danue1/use-async-effekt
- Owner: Danue1
- Created: 2021-06-12T05:19:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-20T07:00:29.000Z (over 3 years ago)
- Last Synced: 2024-04-26T20:07:25.448Z (6 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```