Skip to content

Commit

Permalink
Remove useMemo hook for getData function.
Browse files Browse the repository at this point in the history
(#7)
  • Loading branch information
Thomas Heartman committed Aug 6, 2021
1 parent 6e1bc90 commit 3e411d1
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions next/src/pages/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ const DataDisplay: React.FC<DataDisplayProps> = ({
data: undefined,
});

const getData = React.useMemo(() => () => {
setRemoteData({ status: "Loading", data: remoteData.data });
fetchData()
.then((data) => {
setRemoteData({ status: "Success", data });
})
.catch((err) => {
setRemoteData({
status: "Error",
message: err.message,
data: remoteData.data,
});
});
}, [fetchData, remoteData.data]);
const getData = () => {
setRemoteData({ status: "Loading", data: remoteData.data });
fetchData()
.then((data) => {
setRemoteData({ status: "Success", data });
})
.catch((err) => {
setRemoteData({
status: "Error",
message: err.message,
data: remoteData.data,
});
});
};

return (
<section>
Expand Down

0 comments on commit 3e411d1

Please sign in to comment.