Newer
Older
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
36
37
38
39
40
import React from 'react';
import logo from './logo.svg';
import './App.css';
import { useState, useEffect } from "react";
import axios from "axios";
interface Message {
message: string;
}
function App() {
const [currentMessage, setCurrentMessage] = useState<Message>();
useEffect(() => {
axios.get<Message>("users/test").then(response=> {
setCurrentMessage(response.data);
});
}, []);
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
<p>Current message is {currentMessage?.message}</p>
</header>
</div>
);
}
export default App;