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
<Form onSubmit={this.handleSubmit}> | |
<p> | |
<TextInput name="firstName" placeholder="First Name"/> {' '} | |
<TextInput name="lastName" placeholder="Last Name"/> | |
</p> | |
<p> | |
<SubmitButton>Submit</SubmitButton> | |
</p> | |
</Form> |
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
const withMousePosition = Component => class extends React.Component { | |
state = { | |
mouse: { x: 0, y: 0 } | |
} | |
onMouseMove = e => { | |
this.setState({ mouse: { x: e.clientX, y: e.clientY }}) | |
} | |
componentDidMount() { |
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
const Component = ... | |
const mapStateToProps = ... | |
export default connect(mapStateToProps)(Component) |
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
// a simple feature toggle FaCC | |
const Toggle = () => { | |
const isToggledOn = checkToggle(this.props.toggleName) | |
return this.props.children(isToggledOn) | |
} | |
// and to use it | |
<Toggle toggleName="featureAorB"> | |
{ isToggledOn => isToggledOn ? <FeatureA /> : <FeatureB /> } | |
</Toggle> |
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
// a simple feature toggle FaCC | |
const Toggle = () => { | |
const isToggledOn = checkToggle(this.props.toggleName) | |
return this.props.render(isToggledOn) | |
} | |
// and to use it | |
<Toggle | |
toggleName="featureAorB" | |
render={isToggledOn => isToggledOn ? <FeatureA /> : <FeatureB />} |
OlderNewer