Skip to content

Commit

Permalink
adds onchange and onclick functions #31
Browse files Browse the repository at this point in the history
  • Loading branch information
FarahZaqout committed Nov 4, 2018
1 parent d0808a4 commit 4267f9e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion client/src/components/common/InputField/index.jsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';

// this line disables the windows end of line check for eslint.
/* eslint linebreak-style: ["error", "windows"] */
// declares propTypes validation.
const propTypes = {
type: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
value: PropTypes.string,
placeholder: PropTypes.string,
className: PropTypes.string.isRequired,
onChange: PropTypes.func,
onClick: PropTypes.func,
};

const Input = props => {
const { type, name, value, placeholder, className } = props;
const {
type,
name,
value,
placeholder,
className,
onChange,
onClick,
} = props;

return (
<input
type={type}
placeholder={placeholder}
name={name}
value={value}
className={className}
onChange={onChange}
onClick={onClick}
/>
);
};
Expand All @@ -30,6 +45,8 @@ Input.propTypes = propTypes;
Input.defaultProps = {
value: null,
placeholder: null,
onChange: null,
onClick: null,
};

export default Input;

0 comments on commit 4267f9e

Please sign in to comment.