Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

141
Views
Am building the facebook post in react. and am almost done, but am getting trouble to figure how to close the selected gif in text area

I want to close the gif that is displayed in the text area by clicking on the close button, if I do that am not able to get the gif data again. so I want to select the gif every time I close the gif without refreshing.

import axios from "axios";
import { useState } from "react";
import { useEffect } from "react";
import "./componentsStyles/GifInText.css"
 
const GifInText = ({gifId}) => {

    const [post, setPost] = useState({});
    const [closeGif, setCloseGif] = useState(false)
     

    const fetchData = async () =>{
          await axios.get(`https://api.giphy.com/v1/gifs/${gifId}`,{
                params: { 
                    api_key: "Xoa3mXrWxKXw6lJscrKUTsbZsXLbGuGY",
                    gif_id: gifId
                }
            }).catch((error) =>{
                console.log("error at fetching gifID2", error);
              }).then(response => {
                setPost(response.data)
               
              });
            }
    useEffect(()=>{
        fetchData()
        }, [  ])

        

        return (
            <div className='gif-section'>   
            {post.data && (
                    <>
                    <div className='image-gifs'>
                     <i className="fas fa-times" onClick={()=>setCloseGif(!post)}></i>
                     <img className="live-gifs" src={post.data.images.fixed_height.url} alt="..."/>
                    </div>
                    </>
                )}
            </div> 
         )
}
export default GifInText;
 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!