BAEL-4842 - Use React and Spring Boot to Build a Simple CRUD App

Updating PR to reduce complexity of react components
Fixing react test
This commit is contained in:
Sallo Szrajbman
2021-04-03 13:51:08 +01:00
parent 6a82efdd39
commit 86d75ea394
4 changed files with 22 additions and 23 deletions

View File

@@ -7,16 +7,14 @@ class ClientList extends Component {
constructor(props) {
super(props);
this.state = {clients: [], isLoading: true};
this.state = {clients: []};
this.remove = this.remove.bind(this);
}
componentDidMount() {
this.setState({isLoading: true});
fetch('/clients')
.then(response => response.json())
.then(data => this.setState({clients: data, isLoading: false}));
.then(data => this.setState({clients: data}));
}
async remove(id) {
@@ -33,11 +31,7 @@ class ClientList extends Component {
}
render() {
const {clients, isLoading} = this.state;
if (isLoading) {
return <p>Loading...</p>;
}
const {clients} = this.state;
const clientList = clients.map(client => {
return <tr key={client.id}>