Advertisement
Guest User

Reduxform

a guest
Mar 25th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import React, { Component } from "react";
  2. import {reduxForm, Field } from "redux-form";
  3. import ItemField from "./ItemField";
  4.  
  5. class ItemForm extends Component {
  6. render(){
  7. const {handleSubmit} = this.props;
  8. return(
  9. <div>
  10. <div className="box" id="">
  11. <form className="item" onSubmit={handleSubmit}>
  12. <Field type="text" name="taskName" component={ItemField} placeholder="Add Item"/>
  13. <button type="submit">+</button>
  14. </form>
  15. </div>
  16. </div>
  17. );
  18. }
  19. }
  20.  
  21. function validate(values){
  22. const errors = {};
  23.  
  24. if (!values.taskName) {
  25. errors.taskName ="You must provide a task name";
  26. }
  27.  
  28. return errors;
  29. }
  30.  
  31. export default reduxForm({
  32. validate,
  33. form: "itemForm"
  34. })(ItemForm);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement