-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathAsync.js
56 lines (53 loc) · 1.6 KB
/
Async.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React, {Component} from 'react';
import {Tabs, TabList, Tab, PanelList, AsyncPanel, Panel} from '../../src';
import {Facebook} from 'react-content-loader'
const MyFacebookLoader = () => <Facebook />
function fakeCbFetch(cb) {
setTimeout(() => {
cb(null, {
content: 'hi'
});
}, 1500);
}
function fakePromiseFetch() {
return new Promise((res) => {
setTimeout(() => {
res({
content: 'promise fetched'
});
}, 1500);
})
}
export default class Basic extends Component {
render() {
return (
<Tabs customStyle={this.props.customStyle}>
<TabList>
<Tab>Normal panel</Tab>
<Tab>Callback fetch panel</Tab>
<Tab>Promise fetch panel</Tab>
<Tab>fetch without cache</Tab>
</TabList>
<PanelList>
<Panel>
Normal tab.
You can mix normal panel with async panel
</Panel>
<AsyncPanel loadContent={fakeCbFetch}
render={data => (<div>{JSON.stringify(data)}</div>)}
renderLoading={() => (<MyFacebookLoader/>)}
/>
<AsyncPanel loadContent={fakePromiseFetch}
render={data => (<div>{JSON.stringify(data)}</div>)}
renderLoading={() => (<MyFacebookLoader />)}
/>
<AsyncPanel loadContent={fakePromiseFetch}
render={data => (<div>{JSON.stringify(data)}</div>)}
renderLoading={() => (<MyFacebookLoader />)}
cache={false}
/>
</PanelList>
</Tabs>
)
}
}