Last active
July 6, 2017 19:31
-
-
Save glortho/941d7ead6afe5f8e774c479e0fe5ac67 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 from 'react'; | |
import { container, Children } from 'jetset'; | |
@container({ active: false }) | |
class Panels extends React.Component { | |
getActive = () => this.props.container.get().active; | |
setActive = selected => this.props.container.set({ active: selected }); | |
render() { | |
return Children({ | |
...this.props, | |
Panels: { | |
getActive: this.getActive, | |
setActive: this.setActive | |
} | |
}); | |
} | |
} | |
class Panel extends React.Component { | |
render() { | |
const status = this.props.Panels.getActive(); | |
return ( | |
<div> | |
<span>Active panel is: { String( status ) }</span> | |
<button onClick={() => this.props.Panels.setActive( !status )}>Toggle active</button> | |
</div> | |
); | |
} | |
} | |
export default props => <Panels><Panel { ...props }/></Panels>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment