private-port-test-1
Version:
Una librería de hook para React de ejemplo
15 lines (14 loc) • 331 B
JavaScript
import { useState as t, useEffect as l } from "react";
function h(e) {
const [o, n] = t(null), [a, c] = t(null), [u, r] = t(!0);
return l(() => {
(async () => {
r(!0);
const [f, s] = await e();
s ? c(s) : n(f), r(!1);
})();
}, [e]), { data: o, error: a, loading: u };
}
export {
h as useGetAll
};