import React from 'react'; import './App.css'; import './bootstrap.min.css'; const Empty =

Empty

; const Error =

Error

; class MovementsPage extends React.Component { constructor(props) { super(props); this.state = {loggedIn: props.loggedIn, movements: []}; } componentDidMount() { fetch(this.props.targetUrl + '/movements', {credentials: 'include'}) .then(response => response.json()) .then(data => this.setState({movements: data.movements, loggedIn: data.logged_in})) .catch(error => {console.log(error); this.setState({error: true})}); } componentWillUnmount() { this.setState({error: false, movements: []}); } handleTable() { if (this.state.movements.length > 0) { return ; } else { return Empty; } } render() { const movements =

Movements

{this.handleTable()}
; if (this.state.error) { return Error; } if (this.state.loggedIn) { return movements; } else { return (

You have to login first!

); } } } export default MovementsPage;