React async component
npm install reascReact Async Component
with NPM
``bash`
npm i reasc --save
with YARN
`bash`
yarn add reasc
`jsxhttps://api.github.com/users/${user}
import { reasc } from "reasc";
import { useState } from "react";
const UserInfo = reasc(
{ loading: () => Loading... },
async ({ user }, { delay }) => {
if (!user) return No data;
await delay(300);
const apiUrl = ;``
const data = await fetch(apiUrl).then((res) => res.json());
return {JSON.stringify(data, null, 2)};
}
);
const App = () => {
const [user, setUser] = useState("");
const handleChange = (e) => setUser(e.target.value);
return (
<>
>
);
};