Skip to content

Instantly share code, notes, and snippets.

@DAB0mB
Created August 28, 2018 04:33
Show Gist options
  • Save DAB0mB/569dddfce7668670bd6e92a4687a6ff2 to your computer and use it in GitHub Desktop.
Save DAB0mB/569dddfce7668670bd6e92a4687a6ff2 to your computer and use it in GitHub Desktop.
A sample controller for an Appfairy view
import React from 'react'
import ConsultFormView from '../views/ConsultFormView'
class ConsultFormController extends React.Component {
state = {}
render() {
return (
<ConsultFormView>
<name onChange={this.setName} />
<phone onChange={this.setPhone} />
<email onChange={this.setEmail} />
<description onChange={this.setDescription} />
<submit onClick={this.submit} />
</ConsultFormView>
)
}
setName = (e) => {
this.setState({
name: e.target.value
})
}
setPhone = (e) => {
this.setState({
phone: e.target.value
})
}
setEmail = (e) => {
this.setState({
email: e.target.value
})
}
setDescription = (e) => {
this.setState({
description: e.target.value
})
}
submit = () => {
alert(`
${this.name}
${this.phone}
${this.email}
${this.description}
`)
}
}
export default ConsultFormController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment