-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which animals live in this zoo? #5
Comments
Just a draft: What animals life in this zoo?Form componentsWe house a big family of animals that support with building forms. Example import Immutable from 'immutable'
import React from 'react'
import {Form, InputField, TextareaField, ErrorMessage} from '@epages/react-components'
export default class ContactForm extends React.Component {
constructor () {
super()
this.state = {
value: Immutable.fromJS({
email: '',
message: ''
})
}
this.handleChange = this.handleChange.bind(this)
}
render () {
return (
<Form
name="contactForm"
value={this.state.value}
onSubmit={this.handleSubmit}
validate={this.validate}
normalize={this.normalize}>
<div>
<label>E-Mail</label>
<ErrorMessage name="email"/>
<InputField name="email" type="email" placeholder="Your email"/>
</div>
<div>
<label>Message</label>
<ErrorMessage name="message"/>
<TextareaField name="message" rows={10}/>
</div>
</Form>
)
}
validate (newValue) {
return Immutable.fromJS({
email: email.trim().length > 0 && 'E-Mail is required',
message: message.trim().length > 0 && 'Message is required'
})
}
normalize (newValue) {
return newValue
.update('email', (email) => email.trim())
.update('message', (message) => message.trim())
}
handleSubmit (newValue) {
this.setState({value: newValue})
console.log('Submitted', newValue.toJS())
}
} |
Looks good. A few suggestions:
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since this is an open source project, the README should at least list, if not document the API of, the components.
The text was updated successfully, but these errors were encountered: