Last active
November 20, 2018 00:14
-
-
Save pomber/49d8998ac351a63af2e4845769d7cbc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class App extends React.Component { | |
| state = { | |
| selectedStock: null | |
| }; | |
| render() { | |
| const { stocks } = this.props; | |
| const { selectedStock } = this.state; | |
| return ( | |
| <React.Suspense fallback={<div>Loading...</div>}> | |
| <StockTable | |
| stocks={stocks} | |
| onSelect={selectedStock => this.setState({ selectedStock })} | |
| /> | |
| {selectedStock && ( | |
| <StockChart | |
| stock={selectedStock} | |
| onClose={() => this.setState({ selectedStock: false })} | |
| /> | |
| )} | |
| {/* Preload <StockChart/> */} | |
| <React.Suspense fallback={null}> | |
| <div hidden={true}> | |
| <StockChart stock={stocks[0]} /> | |
| </div> | |
| </React.Suspense> | |
| </React.Suspense> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment