mirror of
https://github.com/mudabbir-ahmad/MAD-Treasure-Hunt.git
synced 2026-10-07 19:00:20 +00:00
24 lines
450 B
JavaScript
24 lines
450 B
JavaScript
import { useEffect, useState } from 'react';
|
|
import { getGameTypes } from '../API/API';
|
|
|
|
const useGameTypeViewModel = () => {
|
|
const [gameTypes, setGameTypes] = useState([]);
|
|
|
|
useEffect(() => {
|
|
let mounted = true;
|
|
getGameTypes().then((types) => {
|
|
if (mounted) {
|
|
setGameTypes(types);
|
|
}
|
|
});
|
|
return () => {
|
|
mounted = false;
|
|
};
|
|
}, []);
|
|
|
|
return { gameTypes };
|
|
};
|
|
|
|
export default useGameTypeViewModel;
|
|
|