Skip to content

Commit ee9a4e2

Browse files
committed
remove knowledge of loading from ContactList
1 parent 68728d5 commit ee9a4e2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

source/views/contacts/contact-list.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export class ContactsListView extends React.PureComponent<void, Props, State> {
5353
}
5454

5555
componentWillMount() {
56-
this.fetchData()
56+
this.fetchData().then(() => {
57+
this.setState(() => ({loading: false}))
58+
})
5759
}
5860

5961
refresh = async () => {
@@ -72,8 +74,6 @@ export class ContactsListView extends React.PureComponent<void, Props, State> {
7274
}
7375

7476
fetchData = async () => {
75-
this.setState(() => ({loading: true}))
76-
7777
let {data: contacts} = await fetchJson(GITHUB_URL).catch(err => {
7878
reportNetworkProblem(err)
7979
return defaultData
@@ -83,7 +83,7 @@ export class ContactsListView extends React.PureComponent<void, Props, State> {
8383
contacts = defaultData.data
8484
}
8585

86-
this.setState(() => ({contacts, loading: false}))
86+
this.setState(() => ({contacts}))
8787
}
8888

8989
onPressContact = (contact: ContactType) => {

0 commit comments

Comments
 (0)