Created
September 26, 2017 12:43
-
-
Save pixeldrew/96fd6f92dbfa225231f639f6ff13877a to your computer and use it in GitHub Desktop.
FARC themed platform components
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 { Component } from 'react'; | |
class BlahComponent extends Component { | |
constructor(props) { | |
super(props); | |
} | |
switchView = () => { | |
this.setState({ aBoolState: !(this.state.aBoolState)}); | |
} | |
render = () => { | |
const switchView = this.switchView; | |
const { aBoolState } = this.state; | |
return ( | |
<div> | |
{this.props.children({switchView}, {aBoolState})} | |
</div> | |
); | |
} | |
} | |
const ThemedBlahComponent = (props)=> ( | |
<BlahComponent {...props}> | |
{({switchView}, {aBoolState}) => ( | |
<div> | |
<button onClick={switchView}>SwitchView</button> | |
<div>aBoolState = {aBoolState}</div> | |
<div>a property passed down from top level {props.woot}</div> | |
</div> | |
)} | |
</BlahComponent> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment