awesome-compose/react-express-mysql/frontend/src/App.js
Jérémie Drouet b58a42015d react-express-mysql: use create-react-app template
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
2020-03-23 13:24:37 +01:00

34 lines
828 B
JavaScript

import React, { useEffect, useState } from "react";
import logo from "./logo.svg";
import "./App.css";
function App() {
const [message, setMessage] = useState();
useEffect(() => {
fetch("/api/")
.then(res => res.json())
.then(res => setMessage(res.message))
.catch(console.error);
}, [setMessage]);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>{message || "Loading..."}</p>
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
}
export default App;