Created
September 1, 2019 21:37
-
-
Save ryanpedersen42/ceb2e37bfe22623f0e5fd4398436abea to your computer and use it in GitHub Desktop.
Second App.jsx Iteration (Dropdown Selector)
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
// 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