-
Notifications
You must be signed in to change notification settings - Fork 29
/
HomePage.js
37 lines (33 loc) · 1 KB
/
HomePage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import ListItem from './ListItem';
import { fetchArtistListJSON } from '../api';
import { Logo } from './Icon/Logo';
import { unstable_createResource } from 'react-cache';
import { Spinner } from './Spinner';
const ArttistListResource = unstable_createResource(fetchArtistListJSON);
class Search extends React.Component {
state = {
// toggles whether to show or hide the inline loading spinner
// just like native iOS!
currentId: null,
};
render() {
return (
<div className="search">
<Logo />
<React.Suspense maxDuration={1000} fallback={<Spinner size="large" />}>
{ArttistListResource.read().map(item => (
<ListItem
to={`/artist/${item.id}`}
onClick={currentId => this.setState({ currentId })}
key={item.id}
item={item}
currentId={this.state.currentId}
/>
))}
</React.Suspense>
</div>
);
}
}
export default Search;