Cook Up a Storm: Build a Recipe Finder App with React ๐Ÿฑ

cook-up-a-storm:-build-a-recipe-finder-app-with-react-

Hey there!๐Ÿ‘‹๐Ÿป, culinary wizards and React aficionados! Are you tired of staring into your empty fridge wondering what to cook? Fear not, because we’re about to embark on a delicious journey to build our very own Recipe Finder app using the magical powers of React.
Get ready to spice up your coding skills and your kitchen adventures!๐Ÿฒ

Ingredients for Success:
Before we start cooking up some code, let’s make sure we have all the necessary ingredients:

  1. A dash of HTML, CSS, and JavaScript knowledge ๐Ÿค“
  2. A pinch of React expertise (don’t worry, we’ll guide you through!๐Ÿ˜Ž)
  3. A dollop of creativity and a sprinkle of humor (optional, but highly recommended๐Ÿคช)

Setting Up Our Kitchen:
First things first, let’s set up our development environment. Fire up your terminal and run the following commands to create a new React app!๐Ÿ”ฅ:

npx create-react-app recipe-finder
cd recipe-finder
npm start

Now that our kitchen is preheating, let’s add some flavor with Tailwind CSS. Run this command to install Tailwind CSS:

npm install tailwindcss@latest postcss-cli autoprefixer

Gathering Ingredients:
Next up, we need to gather our ingredients. We’ll be using the Spoonacular API to fetch delicious recipes. Head over to their website, sign up for a free account, and grab your API key. Now, let’s add some Axios to our project:

npm install axios

Cooking Up the Recipe Finder:
Now comes the fun part โ€“ cooking up our Recipe Finder app! Open up src/App.js and let’s get cooking:

import React, { useState, useEffect } from 'react';
import axios from 'axios';

const App = () => {
  const [query, setQuery] = useState('');
  const [recipes, setRecipes] = useState([]);

  useEffect(() => {
    const fetchRecipes = async () => {
      try {
        const response = await axios.get(
          `https://api.spoonacular.com/recipes/complexSearch?apiKey=YOUR_API_KEY&query=${query}&number=10`
        );
        setRecipes(response.data.results);
      } catch (error) {
        console.error('Error fetching recipes:', error);
      }
    };

    if (query) {
      fetchRecipes();
    }
  }, [query]);

  const handleChange = (event) => {
    setQuery(event.target.value);
  };

  return (
    

Recipe Finder

{recipes.map((recipe) => (
{recipe.title}

{recipe.title}

{recipe.summary}

))}
); }; export default App;

Adding Some Spice with Tailwind CSS ๐Ÿซ•:
Our Recipe Finder app is looking a bit bland, so let’s add some spice with Tailwind CSS! Open up src/index.css and replace its content with the following:

@tailwind base;
@tailwind components;
@tailwind utilities;

Conclusion:
Voilร ! We’ve whipped up a tasty Recipe Finder app using React and spiced it up with Tailwind CSS. Now you can search for mouthwatering recipes to satisfy your cravings and impress your friends with your coding skills.
Keep on cooking, coding, and having fun โ€“ bon appรฉtit! ๐Ÿฝ๏ธ๐Ÿš€

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
no-need-to-learn-class-names-of-css-libraries

No need to learn Class Names of CSS libraries

Next Post
tutorial-on-making-a-database-and-then-using-my-api-template-from-git

Tutorial on making a database and then using my API-Template from GIT

Related Posts