Skip to content

Instantly share code, notes, and snippets.

@alvincrespo
Last active October 30, 2017 13:29
Show Gist options
  • Save alvincrespo/36c3ba65717d3232033a014b0977614a to your computer and use it in GitHub Desktop.
Save alvincrespo/36c3ba65717d3232033a014b0977614a to your computer and use it in GitHub Desktop.
Form Composition with Nested Components
import React, { Component } from 'react';
import Form from './Form';
class App extends Component {
onValidEmail = () => {}
onInvalidEmail = () => {}
render() {
return (
<Form>
{(props) => (
<props.email
onValid={this.onValidEmail}
onInvalid={this.onInvalidEmail}>
{(props) => (
<props.field>
{props.label}
{props.input}
</props.field>
)}
</props.email>
)}
</Form>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment