-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb461ef
commit 5dcb192
Showing
6 changed files
with
61 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { React, useState } from 'react' | ||
import videosData from "../exampleresponse.json" | ||
|
||
const CreateNewVideo = () => { | ||
const [videos, setVideos] = useState([...videosData]) | ||
const [title, setTitle] = useState(""); | ||
const [url, setUrl] = useState(""); | ||
|
||
const titleHandler = (e) => setTitle(e.target.value); | ||
const urlHandler = (e) => setUrl(e.target.value); | ||
|
||
const clickHandler = () => { | ||
const newVid = {} | ||
newVid.id = videosData.length + 1; | ||
newVid.title = title; | ||
newVid.url = url; | ||
|
||
setVideos(videos.push(newVid)); | ||
} | ||
|
||
return ( | ||
<div className="login-div"> | ||
<h1>Create New Video</h1> | ||
<div className="login-box"> | ||
<form> | ||
<div className="user-box"> | ||
<input type="" onChange={titleHandler} value={title} /> | ||
<label>Video Title</label> | ||
</div> | ||
<div className="user-box"> | ||
<input type="" onChange={urlHandler} value={url} /> | ||
<label>Url</label> | ||
</div> | ||
<center> | ||
<button className="btn-submit" onCanPlay={clickHandler}> | ||
SEND | ||
<span></span> | ||
</button> | ||
</center> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
export default CreateNewVideo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters