Open grisena opened 6 years ago
use version "redux-form": "^5.3.6", it will definately solve the problem
You have another error in
<div className ={ form-group ${ title.touched && title.invalid ? 'has-danger' : '' }
>
CHANGE TO
<div className ={ form-group ${ title.touched && title.invalid ? 'has-danger' : '' }
}>
You forget }
CODE: posts_new.js IN LINE{23, 33, 43} https://github.com/justlearncode/react-redux-add-postsReduxSimpleStarter-issues-254/blob/master/posts_new.js
import React, { Component } from 'react'; import { reduxForm } from 'redux-form'; import { createPost } from '../actions/index';
class PostsNew extends Component { render() { const { fields: {title, categories, content}, handleSubmit } = this.props;
} } function validate(values){ const errors ={};
if(!values.title) { errors.title = 'Enter a username'; }
if(!values.categories) { errors.categories = 'Enter categories'; }
if(!values.content) { errors.content = 'Enter some content'; } return errors;
}
export default reduxForm ({
form: 'PostsNewForm', fields: ['title','categories','content'], validate, onSubmit: () => { } },null,{createPost}) (PostsNew);
HELP PLEASE!!! Submit button seems to not work and also the validation.