Created
November 14, 2018 19:14
-
-
Save pomber/0dd2ade6f78105b17b9dc71ecf0e3871 to your computer and use it in GitHub Desktop.
This file contains 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
import React from "react"; | |
import StockTable from "./StockTable"; | |
import StockChart from "./StockChart"; | |
class App extends React.Component { | |
state = { | |
selectedStock: null | |
}; | |
render() { | |
const { stocks } = this.props; | |
const { selectedStock } = this.state; | |
return ( | |
<React.Fragment> | |
<StockTable | |
stocks={stocks} | |
onSelect={selectedStock => this.setState({ selectedStock })} | |
/> | |
{selectedStock && ( | |
<StockChart | |
stock={selectedStock} | |
onClose={() => this.setState({ selectedStock: false })} | |
/> | |
)} | |
</React.Fragment> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment