Advertisement
Miii7aka

custom hook for search

Aug 7th, 2024
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export function useGetAllArtists() {
  2.     const [artist, setArtists] = useState([]);
  3.  
  4.     useEffect(() => {
  5.         (async () => {
  6.             try {
  7.                 const result = await artistAPI.getAll();
  8.                 setArtists(result);
  9.             } catch (err) {
  10.                 console.error('Error fetching artists:', err);
  11.                 throw err;
  12.             }
  13.         })();
  14.     }, []);
  15.  
  16.     return artist;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement