{"size": 798, "ext": "js", "max_stars_repo_path": "src/components/WordForm.js", "max_stars_repo_name": "vyasriday/word-wiki", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/WordForm.js", "max_issues_repo_name": "vyasriday/word-wiki", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/WordForm.js", "max_forks_repo_name": "vyasriday/word-wiki", "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": 17.7333333333, "max_line_length": 52, "alphanum_fraction": 0.5839598997}
import React, { useState } from 'react';

const WordForm = (props) => {
	const [word, setWord] = useState({
		name: '',
		definition: '',
	});

	function handleWord(e) {
		const { name, value } = e.target;
		setWord({ ...word, [name]: value.toLowerCase() });
	}

	function handleSubmit(e) {
		e.preventDefault();
		props.handleSubmit(word);
		setWord({ name: '', definition: '' });
	}
	return (
		<form onSubmit={handleSubmit}>
			<label>
				Name
				<input
					name='name'
					type='text'
					value={word.name}
					onChange={handleWord}
				/>
			</label>
			<label>
				Definition
				<input
					name='definition'
					type='text'
					value={word.definition}
					onChange={handleWord}
				/>
			</label>
			<button type='submit'>Submit</button>
		</form>
	);
};

export default WordForm;
