Commit 4fffcd8d by Moorthy G

add proptypes to todoform

parent 8e390a37
import React, { useState } from "react";
import PropTypes from 'prop-types';
import React, { useState } from 'react';
function TodoForm(props) {
const [input, setInput] = useState("");
const [input, setInput] = useState('');
const onChange = (e) => {
setInput(e.target.value);
......@@ -10,31 +10,34 @@ function TodoForm(props) {
const Submit = (e) => {
e.preventDefault();
props.onSubmit({
id: Math.floor(Math.random() * 10000),
text: input,
status: false
status: false,
});
setInput("");
setInput('');
};
return (
<>
<form onSubmit={Submit}>
<div className="add-form">
<div className='form-control'>
<input
placeholder="Enter Item"
value={input}
onChange={onChange}
name="text" />
</div>
<button className="btn" onClick={Submit}>Submit</button>
<form onSubmit={Submit}>
<div className='add-form'>
<div className='form-control'>
<input
placeholder='Enter Item'
value={input}
onChange={onChange}
name='text'
/>
</div>
</form>
</>
<button className='btn' onClick={Submit}>
Submit
</button>
</div>
</form>
);
}
export default TodoForm;
TodoForm.propTypes = {
onSubmit: PropTypes.func,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment