add function creatPost and login wp
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { fetchPosts, deletePost } from "../../wordpress";
|
||||
|
||||
function PostList() {
|
||||
const [posts, setPosts] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
async function loadPosts() {
|
||||
const data = await fetchPosts();
|
||||
setPosts(data);
|
||||
}
|
||||
loadPosts();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="post-list">
|
||||
<h2>Liste des Articles</h2>
|
||||
{posts.map((post) => (
|
||||
<div key={post.id} className="post-item">
|
||||
<h3>{post.title.rendered}</h3>
|
||||
<button onClick={() => deletePost(post.id)}>Supprimer</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export default PostList;
|
||||
Reference in New Issue
Block a user