SHARE
TWEET

Reduxform

a guest Mar 25th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top