-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
35 lines (29 loc) · 740 Bytes
/
App.js
File metadata and controls
35 lines (29 loc) · 740 Bytes
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
import React, { useState, useEffect } from 'react';
import './App.css';
function App() {
const [posts, setPosts] = useState([]);
const [loading, setLoading] = useState(true);
// REPLACE WITH YOUR WORDPRESS URL
const WP_API_URL = 'http://your-local-site.local/wp-json/wp/v2/posts';
useEffect(() => {
// Fetch posts from WordPress
// Your code here
}, []);
return (
<div className="App">
<header>
<h1>React Headless CMS Demo</h1>
</header>
<main>
{loading ? (
<p>Loading...</p>
) : (
<div className="posts-container">
{/* Display posts here */}
</div>
)}
</main>
</div>
);
}
export default App;