/
App.js
32 lines (28 loc) · 790 Bytes
/
App.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
import React from 'react'
import universal from 'react-universal-component'
const UniversalTab = universal(({ tab }) => import(`./${tab}`))
export default class App extends React.Component {
state = { selected: 'Home' }
render() {
return (
<div>
<UniversalTab tab={ this.state.selected } />
<button onClick={ () =>
this.setState({ selected: 'Home' }) }>
Home
</button>
<button onClick={ () =>
this.setState({ selected: 'Foo' }) }
onMouseEnter={ () =>
UniversalTab.preload({ tab: 'Foo' }) }
>
Foo
</button>
<button onClick={ () =>
this.setState({ selected: 'Bar' }) }>
Bar
</button>
</div>
)
}
}