Advertisement
DarioDEBATECH

TextFieldGroup.js

Jan 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //TextFieldGroup.js
  2. import React from 'react';
  3. import classnames from 'classnames';
  4. import PropTypes from 'prop-types';
  5.  
  6. const TextFieldGroup = ({
  7.    name,
  8.    placeholder,
  9.    value,
  10.    label,
  11.    error,
  12.    info,
  13.    type,
  14.    onChange,
  15.    disabled
  16. }) => {
  17.    return (
  18.       <div className="form-group">
  19.          {/* <label>{name}</label> */}
  20.          <input
  21.             type={type}
  22.             className={classnames('form-control form-control-lg', { 'is-invalid': error })}
  23.             placeholder={placeholder}
  24.             name={name}
  25.             value={value} //discutible
  26.             onChange={onChange}
  27.             disabled={disabled}
  28.          />
  29.          {info && <small className="form-text text-muted">{info}</small>}
  30.          {error && <div className="invalid-feedback">{error}</div>}
  31.       </div>
  32.    );
  33. };
  34.  
  35. TextFieldGroup.propTypes = {
  36.    name: PropTypes.string.isRequired,
  37.    placeholder: PropTypes.string,
  38.    value: PropTypes.string.isRequired,
  39.    info: PropTypes.string,
  40.    error: PropTypes.string,
  41.    type: PropTypes.string.isRequired,
  42.    onChange: PropTypes.func.isRequired,
  43.    disabled: PropTypes.string
  44. }
  45.  
  46. TextFieldGroup.defaultProps = {
  47.    type: 'text'
  48. }
  49.  
  50.  
  51. export default TextFieldGroup;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement