Processing asynchronous data in react functional components.
npm install react-await-utilshell
npm install react-await-util
`
$3
`jsx
import {useState} from "react";
import {isPending, useAwaitWatch} from "react-await-util";
import {Skeleton, Button, Flex, Spin} from "antd";
export default function App() {
const [count, setCount] = useState(0);
const add = () => setCount(count + 1);
const [{first, status, value}, {update}] = useAwaitWatch({
deps: count,
handle: async (count) => {
await new Promise(resolve => setTimeout(resolve, 1000));
return "hello" + count;
},
});
return (
{count} - {value}
);
}
``