HiddenField.js
1.2 KB
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
import React,{PropTypes} from 'react';
import ReactDOM from 'react-dom';
import cx from 'classnames';
import s from './reduxfields.scss';
class HiddenField extends React.Component {
constructor(props) {
super(props);
this.validationState=this.validationState.bind(this);
}
static propTypes = {
field:PropTypes.object,
onChange:PropTypes.func,
placeholder:PropTypes.string
}
static defaultProps={
placeholder:''
}
validationState(field){
if(field.error&&field.touched){
return 'error';
}else if(field.touched)
return null;
else
return null;
}
componentDidMount(){
}
componentWillReceiveProps(nextProps){
}
componentDidUpdate(prevProps,prevState){
}
componentWillUnmount() {
}
render(){
const {field,onChange,placeholder}=this.props;
return (
<div >
<input type="hidden" onChange={field.onChange} placeholder={placeholder} value={field.value} />
<div>{field.touched?field.error:''}</div>
</div>
)
}
}
export default HiddenField;