File size: 1,024 Bytes
7d51e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React, { useRef } from "react";

const VideoAdButton = () => {
  const adContainerRef = useRef(null);

  const handleClick = () => {
    if (!adContainerRef.current.querySelector("iframe")) {
      const script = document.createElement("script");
      script.src = "https://strong-training.com/dIm.FKzqdbGmNmvXZ/GEUr/We/m/9TuGZTUillkZPITRY/3DNOjNIK0QMAzdEOttNRjlcw2JMdjcQ/zBM_ge";
      script.async = true;
      adContainerRef.current.appendChild(script);
    }
  };

  return (
    <div style={{ width: "100%", textAlign: "center", margin: "24px 0" }}>
      <button
        onClick={handleClick}
        style={{
          padding: "12px 32px",
          fontSize: "1.1em",
          background: "#0070f3",
          color: "#fff",
          border: "none",
          borderRadius: "6px",
          cursor: "pointer",
          marginBottom: "12px"
        }}
      >
        Click here to watch a video ad
      </button>
      <div ref={adContainerRef}></div>
    </div>
  );
};

export default VideoAdButton;