{"size": 1147, "ext": "js", "max_stars_repo_path": "react-project/src/components/TextInput/TextInput.js", "max_stars_repo_name": "lukemico/react-space-launch-spa", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "react-project/src/components/TextInput/TextInput.js", "max_issues_repo_name": "lukemico/react-space-launch-spa", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "react-project/src/components/TextInput/TextInput.js", "max_forks_repo_name": "lukemico/react-space-launch-spa", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.4406779661, "max_line_length": 56, "alphanum_fraction": 0.6425457716}
import React from 'react';
import PropTypes from 'prop-types';

import styles from './text-input.module.scss';

/**
 * Renders a simple text field with label
 */
const TextInput = ({
  value,
  label,
  onChange,
  placeholder,
  uid
}) => (
  <div className={styles.textInput}>
    <label className={styles.label} htmlFor={uid}>
      {label}
    </label>
    <input
      id={uid}
      className={styles.field}
      type="text"
      placeholder={placeholder}
      value={value}
      onChange={e => {
        onChange(e.target.value);
      }}
    />
  </div>
);

TextInput.propTypes = {
  // the current value of the text input
  value: PropTypes.string,

  // the label for the text input
  label: PropTypes.string.isRequired,

  // the function that is called when the user
  // updates the text
  onChange: PropTypes.func,

  // what text should be shown in the placeholder
  placeholder: PropTypes.string,

  // a unique identifier for the input so that the label
  // can be tied to it
  uid: PropTypes.string.isRequired
};

TextInput.defaultProps = {
  value: '',
  onChange: () => {},
  placeholder: '',
}

export default TextInput;
