MCPcopy Create free account
hub / github.com/RobPruzan/react-scratch / DataFetcher

Function DataFetcher

src/script.ts:614–635  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

612};
613
614const DataFetcher = () => {
615 const [data, setData] = React.useState<Array<any>>([]);
616
617 React.useEffect(() => {
618 console.log("fetching");
619 fetch("https://jsonplaceholder.typicode.com/posts")
620 .then((response) => response.json())
621 .then((data) => {
622 setData(data);
623 });
624
625 return () => {
626 setData([]);
627 };
628 }, []);
629
630 return React.createElement(
631 "div",
632 null,
633 ...data.map((item) => React.createElement("div", { innerText: item.title }))
634 );
635};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected