import React, { useEffect, useState } from "react";

const Header = () => {
  const [gifUrl, setGifUrl] = useState(null);
  useEffect(() => {
    async function getGif() {
      const response = await fetch(
        "//api.giphy.com/v1/gifs/random?tag=christmas&api_key=3ziHSa4ptYJdv2dOuawgzpBhhiW09Ss1"
      );
      const { data } = await response.json();
      console.log(data)
      setGifUrl(data.image_webp_url);
    }

    getGif();
  }, []);

  return (
    <div className="header">
      <h1>Bello's Adventskalender 2020</h1>
      {gifUrl && (
        <video className="yay-gif-video" src={gifUrl} autoPlay loop muted />
      )}
    </div>
  );
};

export default Header;
