Revize ff054af2
Přidáno uživatelem Petr Urban před asi 2 roky(ů)
ui/src/App.tsx | ||
---|---|---|
1 | 1 |
import React from 'react'; |
2 |
import logo from './logo.svg'; |
|
3 |
import './App.css'; |
|
2 |
import { useState, useEffect } from 'react'; |
|
3 |
import axios from 'axios' |
|
4 |
|
|
5 |
const App = () => { |
|
6 |
|
|
7 |
let [data, setData] = useState(null); |
|
8 |
let [loading, setLoading] = useState(false); |
|
9 |
|
|
10 |
useEffect(() => { |
|
11 |
setLoading(true); |
|
12 |
|
|
13 |
axios |
|
14 |
.get("http://localhost:8080/v2/testCall") |
|
15 |
.then((result) => { |
|
16 |
setData(result.data.response); |
|
17 |
setLoading(false); |
|
18 |
}) |
|
19 |
.catch((error) => console.log(error)); |
|
20 |
}, []); |
|
21 |
|
|
22 |
if (loading) { |
|
23 |
return <p>Loading...</p> |
|
24 |
} |
|
25 |
|
|
4 | 26 |
|
5 |
function App() { |
|
6 | 27 |
return ( |
7 |
<div className="App"> |
|
8 |
<header className="App-header"> |
|
9 |
<img src={logo} className="App-logo" alt="logo" /> |
|
10 |
<p> |
|
11 |
Edit <code>src/App.tsx</code> and save to reload. |
|
12 |
</p> |
|
13 |
<a |
|
14 |
className="App-link" |
|
15 |
href="https://reactjs.org" |
|
16 |
target="_blank" |
|
17 |
rel="noopener noreferrer" |
|
18 |
> |
|
19 |
Learn React |
|
20 |
</a> |
|
21 |
</header> |
|
22 |
</div> |
|
28 |
<div className="container">{data}</div> |
|
23 | 29 |
); |
24 |
} |
|
30 |
}; |
|
31 |
|
|
25 | 32 |
|
26 | 33 |
export default App; |
Také k dispozici: Unified diff
new: #10050 Vytvořit ReactJS strukturu; created dummy controller and ReactJS module. Tested controller call