vite-bugs/packages/hello-world/hello.tsx

51 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2024-03-16 22:48:55 +00:00
import React from "react";
import op from "object-path";
import config from "~/config";
2024-03-16 23:16:22 +00:00
import ky from "ky";
2024-03-16 22:48:55 +00:00
// const config = {
// title: "Hello World",
// description: "Hello World description",
// };
const data = {
title: "Hello World",
description: "Hello World description",
og: {
title: config.title,
description: config.description,
image: "https://duogeeks.com/images/logo.png",
},
};
const HelloWorld: React.FC = () => {
2024-03-16 23:16:22 +00:00
const [state, setState] = React.useState([]);
React.useEffect(() => {
ky.get("https://jsonplaceholder.typicode.com/todos/")
.json()
.then((data) => {
setState(data);
});
}, []);
2024-03-16 22:48:55 +00:00
return (
<div>
<strong>Hello World !</strong>
<p>{data.description}</p>
<p>Name: {op.get(data, "og.title")}</p>
2024-03-16 23:16:22 +00:00
<div>
<h3>TODO Data</h3>
<ul>
{state.map((item, index) => (
<li key={index}>
{item.completed ? "✅" : "🤷"} - {item.title} (#{item.id})
</li>
))}
</ul>
</div>
2024-03-16 22:48:55 +00:00
</div>
);
};
export default HelloWorld;