Skip to content

Instantly share code, notes, and snippets.

@omas-public
Last active February 1, 2023 07:43
Show Gist options
  • Save omas-public/1bdbe6decf0253460ad487d07347e163 to your computer and use it in GitHub Desktop.
Save omas-public/1bdbe6decf0253460ad487d07347e163 to your computer and use it in GitHub Desktop.
import axios from "axios";
import { useState, useEffect } from "react";
const baseURL = "https://jsonplaceholder.typicode.com/users/1";
const print = JSON.stringify
const Item = ({ user }) => (
<li>{user}</li>
)
const Main = ({ users }) => {
return (
<ul><Item id={users.id} name={users.name} /></ul>
)
}
const App = () => {
const [users, setUsers] = useState(null);
useEffect(() => {
axios.get(baseURL).then((res) => {
setUsers(res.data);
});
}, []);
if (!users) return <p>Now Loading....</p>;
return (
<div>
<Main users={users} />
</div>
);
}
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment