Skip to content

Instantly share code, notes, and snippets.

@jeremt

jeremt/App.jsx Secret

Created July 4, 2023 06:54
Show Gist options
  • Save jeremt/3f0e0bb8c73475bf26b4c5bdd4b1b596 to your computer and use it in GitHub Desktop.
Save jeremt/3f0e0bb8c73475bf26b4c5bdd4b1b596 to your computer and use it in GitHub Desktop.
import {useAsync} from 'react-use';
const App = () => {
const {loading, value, error} = useAsync(async () => (await fetch("https://dummyjson.com/todos")).json());
console.log(loading, value, error)
if (loading) {
return <div>Loading...</div>
}
if (error) {
return <div>Error: {error.message}</div>
}
return <div>{JSON.stringify(value)}</div>
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment