GitHub

Original file line numberDiff line numberDiff line change

@@ -2,23 +2,14 @@

22
33

import React from "react";

44
5-

export type ComponentFetchProps = {

6-
7-

}

8-
9-

export function ComponentFetch(props: ComponentFetchProps) {

10-
11-
5+

export function ComponentFetch() {

126

const [data, setData] = React.useState(null);

137
148

React.useEffect(() => {

159

fetch("https://jsonplaceholder.typicode.com/posts/1").then((res) => res.json()).then((d) => setData(d))

1610

}, [])

1711
18-
1912

return <div>

20-
2113

{JSON.stringify(data)}

2214

</div>

23-
2415

}

Read the original on github.com ↗