Skip to content

Commit

Permalink
Cleaned up Moderation Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
olafwrieden committed Jun 7, 2020
1 parent cb21d27 commit d215cd0
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions client/src/components/Moderation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,10 @@ import Entry from "./components/Entry";

const Moderation = () => {
const [data, setData] = useState([]);
const [loading, setLoading] = useState(false);
const [pageCount, setPageCount] = useState(0);
const [totalItems, setTotalItems] = useState(0);
const fetchIdRef = useRef(0);

const pageIndex = 0;
const pageSize = 10;

const fetchData = useCallback(async ({ pageSize, pageIndex }) => {
const fetchData = useCallback(async () => {
const fetchId = ++fetchIdRef.current;
setLoading(true);

// Fetch Data
const data = await fetch(
Expand All @@ -26,18 +19,15 @@ const Moderation = () => {

if (fetchId === fetchIdRef.current) {
setData(data.data);
setTotalItems(data.totalItems);
setPageCount(data.totalPages);
setLoading(false);
}
}, []);

useEffect(() => {
fetchData({ pageIndex, pageSize });
}, [fetchData, pageIndex, pageSize]);
fetchData(0, 10);
}, [fetchData]);

const refreshPage = () => {
fetchData({ pageIndex, pageSize });
fetchData(0, 10);
};

return (
Expand Down

0 comments on commit d215cd0

Please sign in to comment.