ReactJS: add loading state
- use 8081 port for talking to SpringBoot (as 8080 occupied by Corda)
This commit is contained in:
parent
55d086bbe2
commit
db3cf0ee29
@ -17,7 +17,7 @@
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"proxy": "http://localhost:8080",
|
||||
"proxy": "http://localhost:8081",
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
|
@ -3,7 +3,8 @@ import React, { useState, useEffect } from 'react';
|
||||
|
||||
function App() {
|
||||
|
||||
const [joke, setJoke] = useState([]);
|
||||
const [joke, setJoke] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/badjokes')
|
||||
.then((response) => response.json())
|
||||
@ -20,7 +21,7 @@ function App() {
|
||||
<div className="App">
|
||||
<header className="App-header">
|
||||
<p>
|
||||
Here is your joke: {joke}
|
||||
Here is your joke: {joke ? <span>{joke}</span> : <span>Loading...</span>}
|
||||
</p>
|
||||
</header>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user