I'm sending a request like this:
function getDecks() {
return Axious.get(urlGetAllDecks).then((response) => response.data);
}
I'm then using a functional component, where I try to initialize the state by calling the above function from my database.js file. However, the useEffect block is called countless times.
export interface DeckSelectionState {
id: number;
module: number;
title: string;
description: string;
dateCreated: string;
reviewStatus: number;
nextReviewDate: string;
}
const DeckSelection: React.FunctionComponent = () => {
const [decks, setDecks] = React.useState<DeckSelectionState[]>([]);
React.useEffect(() => {
database.getDecks().then((response) => {
setDecks(response);
});
});
Any idea on how to fix this?