Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. # withForm
  2.  
  3. `withForm` is a higher order component that handles all the nitty gritty for managing simple forms, such as hooking up onChange handlers, validation etc.
  4.  
  5. ### Simple Example
  6.  
  7. ```
  8. import React from 'react'
  9. import withForm from 'constructicon/lib/form
  10. import InputField from 'constructicon/input-field
  11.  
  12. const form = {
  13. email: {
  14. label: 'Email'
  15. },
  16. password: {
  17. label: 'Password',
  18. type: 'password'
  19. }
  20. }
  21.  
  22. const LoginForm = ({
  23. fields
  24. }) => (
  25. <div>
  26. <InputField {...fields.email} />
  27. <InputField {...fields.password} />
  28. </div>
  29. )
  30.  
  31. export default withForm(form)(LoginForm)
  32. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement