×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Mirko Jelic
Added: Feb 9, 2019 11:02 AM
Views: 3735
Tags: react
  1. import React from 'react'
  2. import classNames from 'classnames'
  3.  
  4.  
  5.  
  6. const InputGroup = (
  7.   {
  8.     name,
  9.     placeholder,
  10.     value,
  11.     label,
  12.     error,
  13.     icon,
  14.     info,
  15.     type = 'text',
  16.     onChange,
  17.     disabled
  18.   }
  19.  
  20. ) => {
  21.  
  22.   return (
  23.     <div className='form-control'>
  24.       <img src={icon} className='icon' alt='icon'/>
  25.       <input
  26.         type={type}
  27.         className={classNames('form-control__input',{'form-control__input--invalid':error})}
  28.         placeholder={placeholder}
  29.         name={name}
  30.         value={value}
  31.         onChange={onChange}
  32.         disabled={disabled}
  33.       />
  34.       {error && <div className="form-control__invalid--feedback">{error}</div>}
  35.     </div>
  36.   )
  37. }
  38.  
  39. export default InputGroup
  40.