A fun React project that generates random GIFs using the GIPHY API.
It demonstrates the use of custom hooks (useGif
) to handle API logic, loading states, and reusability between multiple components (Random
and Tag
).
- Fetches random GIFs from GIPHY API
- Includes two components:
- Random GIF: Displays completely random GIFs
- Tag GIF: Displays GIFs based on a custom tag (e.g., “cats”, “dogs”)
- Built with a Custom Hook (
useGif
) for reusable API logic - Responsive UI with Tailwind CSS
- Spinner shown while loading
- Creating and using Custom Hooks in React
- Working with Axios to fetch API data
- Managing loading states efficiently
- Using environment variables in Vite projects
- Structuring clean and reusable React components
src/
┣ components/
┃ ┣ Random.jsx
┃ ┣ Spinner.jsx
┃ ┗ Tag.jsx
┣ hooks/
┃ ┗ useGif.jsx
┣ App.jsx
┣ main.jsx
┣ index.css
┗ .env
- React.js (Vite)
- Tailwind CSS
- Axios
- Custom Hooks
- GIPHY API
-
Clone the repository:
git clone https://github.com/ReetuGupta/React-Gif-Generator.git cd React-Gif-Generator
-
Install dependencies:
npm install
-
Create a .env file in the root directory and add your GIPHY API key:
VITE_APP_GIPHY_API_KEY=your_api_key_here
-
Run the development server:
npm run dev
-
Open your browser and visit:
http://localhost:5173
- The custom hook useGif handles:
- Fetching GIF data from GIPHY API
- Managing loading state
- Returning gif, loading, and fetchData for reuse
- Random.jsx calls useGif() with no tag for random GIFs.
- Tag.jsx calls useGif(tag) to get GIFs based on user input.
- Add category dropdown for quick tag selection
- Save favorite GIFs
- Infinite scroll for continuous GIF loading
- Copy GIF URL / Download option
- Dark/Light mode
- Made with ❤️ by REETU GUPTA
- 🌐 Portfolio: My Portfolio
- 📩 Reach me: reetu.gupta703@gmail.com