Skip to content

Instantly share code, notes, and snippets.

@pixeldrew
Created September 26, 2017 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixeldrew/96fd6f92dbfa225231f639f6ff13877a to your computer and use it in GitHub Desktop.
Save pixeldrew/96fd6f92dbfa225231f639f6ff13877a to your computer and use it in GitHub Desktop.
FARC themed platform components
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