-
-
Save joshin-run/420423e566944db5c483691e73fc45bc 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, { Component } from 'react' | |
import Header from './Header' | |
import Sidebar from './Sidebar' | |
export default class App extends Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
isSidebarOpen: false | |
} | |
} | |
toggleSidebar = () => { | |
this.setState({isSidebarOpen: !this.state.isSidebarOpen}) | |
} | |
render() { | |
return ( | |
<div> | |
<Header | |
onToggleSidebar={this.toggleSidebar} | |
/> | |
<Sidebar | |
isSidebarOpen={this.state.isSidebarOpen} | |
/> | |
</div> | |
) | |
} | |
} |
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, { Component } from 'react' | |
export default class Header extends Component { | |
constructor(props) { | |
super(props) | |
this.state = {/* Header doing its own thing with state */} | |
} | |
toggleSidebar = () => { | |
this.props.onToggleSidebar() | |
} | |
render() { | |
return ( | |
<div className="header"> | |
<button type="button" onClick={this.toggleSidebar}>Toggle Sidebar</button> | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment