diff --git a/src/App.js b/src/App.js index da4f18c..1cff96b 100644 --- a/src/App.js +++ b/src/App.js @@ -3,6 +3,7 @@ import firebase from "./firebase"; import { AddArticle } from "./pages/add_article"; import IndexArticle from "./pages/index_article"; import ShowArticle from "./pages/show_article"; +import UpdateArticle from "./pages/update_article"; import { getPrivateMessage } from "./api"; import { useState, useEffect } from "react"; import { BrowserRouter as Router, Route, Link } from "react-router-dom"; diff --git a/src/pages/update_article.js b/src/pages/update_article.js new file mode 100644 index 0000000..582c2c0 --- /dev/null +++ b/src/pages/update_article.js @@ -0,0 +1,29 @@ +import React from "react"; +import { useState, useEffect } from "react"; +import { getArticle } from "../api"; + +const UpdateArticle = props => { + const [article, setArticle] = useState({}); + const [title, setTitle] = useState("") + const [body, setBody] = useState("") + + useEffect(() => { + const id = props.p.match.params.id; + + getArticle(id).then(resp => { + setArticle(resp.Article); + setTitle(resp.Article.title) + setBody(resp.Article.body); + }); + }, []); + + return ( +
+ setTitle(e.target.value)}/> +