Skip to content

Commit

Permalink
Create App.js
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiiCodes authored Aug 13, 2023
1 parent 00fc315 commit 7bf6005
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions react/react-reels-downloader/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//test Url https://www.instagram.com/reel/CvzvzCQNR9J/?igshid=MzRlODBiNWFlZA==
// App.js
import React, { useState } from 'react';
import { downloadInstagramVideo } from './api';
import './index.css';
import Loader from './Loader';

function App() {
const [videoUrl, setVideoUrl] = useState('');
const [videoData, setVideoData] = useState(null);
const [isLoading, setIsLoading] = useState(false);

const handleDownload = async () => {
if (videoUrl) {
setIsLoading(true);
try {
const data = await downloadInstagramVideo(videoUrl);
setVideoData(data);
} catch (error) {
console.error(error);
}
setIsLoading(false);
}
};

return (
<div className="container">
<video className="background-video" loop muted autoPlay>
<source src="https://res.cloudinary.com/deafnuhyi/video/upload/v1691920847/Untitled_cjlqzp.mov" type="video/mp4" />
</video>
// This video url will expire in Aug 15, 2023.
// feel free to remove it or replace it with your own.
<div className="content">
<h1 className="heading">Instagram Reel Video Downloader</h1>
<input type="text" className="input"
placeholder="Reel Url" value={videoUrl}
onChange={(e) => setVideoUrl(e.target.value)}
/>
{isLoading ? (
<div><Loader /></div>
) : (
videoData && (
<div className="video-section">
<video className="video-player" controls>
<source src={videoData.media} type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
)
)}
<button className="button" onClick={handleDownload}>
<span>Download</span></button>
</div>
</div>
);
}

export default App;

0 comments on commit 7bf6005

Please sign in to comment.