rm need for separate loading boolean in state

This commit is contained in:
Collin M. Barrett 2019-08-05 14:58:22 -05:00
parent b779a9de45
commit dc7325b7de
3 changed files with 21 additions and 24 deletions

Binary file not shown.

View file

@ -38,4 +38,4 @@
"last 1 safari version"
]
}
}
}

View file

@ -4,32 +4,29 @@ import { nameof } from '../../utils';
import { List } from './List';
interface State {
data: List[];
loading: boolean;
data: List[];
}
export class AllListsTable extends React.Component<{}, State> {
constructor(props: any) {
super(props);
this.state = {
data: [],
loading: false,
};
}
constructor(props: any) {
super(props);
this.state = {
data: []
};
}
componentDidMount() {
this.setState({ loading: true });
fetch("/api/v1/lists")
.then(response => response.json())
.then(json => { this.setState({ data: json, loading: false }); })
}
componentDidMount() {
fetch("/api/v1/lists")
.then(response => response.json())
.then(json => { this.setState({ data: json }); })
}
render() {
return (
<Table<List> dataSource={this.state.data} rowKey={record => record.id.toString()} loading={this.state.loading} size="small" pagination={{ position: "top", size: "small" }} >
<Table.Column<List> title="Name" dataIndex={nameof<List>("name")} width={250} fixed="left" />
<Table.Column<List> title="Description" dataIndex={nameof<List>("description")} />
</Table>
);
}
render() {
return (
<Table<List> dataSource={this.state.data} rowKey={record => record.id.toString()} loading={this.state.data.length > 0 ? false : true} size="small" pagination={{ position: "top", size: "small" }} >
<Table.Column<List> title="Name" dataIndex={nameof<List>("name")} width={250} fixed="left" />
<Table.Column<List> title="Description" dataIndex={nameof<List>("description")} />
</Table>
);
}
}