-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathErrorFormMessage.js
51 lines (43 loc) · 1.05 KB
/
ErrorFormMessage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { cleanErrors } from '../../actions/auth.actions';
class ErrorFormMessage extends React.PureComponent {
static propTypes = {
errors: PropTypes.arrayOf(PropTypes.string).isRequired,
cleanErrors: PropTypes.func.isRequired,
};
componentWillUnmount() {
const { cleanErrors } = this.props;
cleanErrors();
}
render() {
const { errors } = this.props;
return (
<div className="formErrors">
<div>
<ul>
{errors.map(item => (
<div key={item}>
<li>
<p>{item}</p>
</li>
</div>
))}
</ul>
<div className="alert alert-danger">Form invalid, please check again</div>
</div>
</div>
);
}
}
const mapStateToProps = state => ({
user: state.auth,
});
const mapDispatchToProps = {
cleanErrors,
};
export default connect(
mapStateToProps,
mapDispatchToProps
)(ErrorFormMessage);