-
-
Save michaelmcshinsky/9414d0d26060b1f9ce34ea732d48d520 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
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 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
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