awesome-compose/react-rust-postgres/frontend/src/App.js
Jérémie Drouet bed22c74f5 react-rust-postgres: create simple client
Signed-off-by: Jérémie Drouet <jeremie.drouet@gmail.com>
2020-03-25 16:22:24 +01:00

35 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;