Created
September 2, 2019 01:00
-
-
Save ryanpedersen42/539155bd0f843e3ce136507711aa9de1 to your computer and use it in GitHub Desktop.
Fourth App.jsx Iteration (Dropdown Menu)
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
// src/App.jsx | |
// ...imports removed for brevity | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
box: null, | |
ethAddress: '', | |
userProfile: {}, | |
isAppReady: false, | |
selectedSpace: '', // *NEW* addition | |
dappStorage: [], // *NEW* addition | |
}; | |
} | |
// ...functions removed for brevity | |
// *NEW* change space that actions are being taken on | |
changeSelectedSpace = async (event) => { | |
const { box } = this.state; | |
const selectedSpace = event.target.value; | |
const dappStorage = await box.openSpace(selectedSpace); | |
await this.setState({ selectedSpace, dappStorage }); | |
} | |
render() { | |
const { isAppReady, ethAddress, spaceOptions, selectedSpace } = this.state; | |
return ( | |
<div className="App"> | |
{isAppReady && (<Fragment> | |
<Switch> | |
{/* Auth route removed for brevity */} | |
<Route | |
exact | |
path='/main' | |
render={() => ( | |
<MainPage | |
//state | |
ethAddress={ethAddress} | |
spaceOptions={spaceOptions} | |
selectedSpace={selectedSpace} | |
//functions | |
changeSelectedSpace={this.changeSelectedSpace} | |
/> | |
)} | |
/> | |
</Switch> | |
</Fragment>)} | |
</div> | |
); | |
} | |
} | |
export default withRouter(App); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment