Last active
October 20, 2018 18:27
-
-
Save lomse/bf335032afeef111115f2fc5126c54b9 to your computer and use it in GitHub Desktop.
TodoForm.jsx to add new todos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import styled from 'styled-components' | |
import PropTypes from 'prop-types' | |
const FormInput = styled.input` | |
width: 235px; | |
outline: none; | |
font-size: 13px; | |
padding-top: 7px; | |
padding-bottom: 7px; | |
padding-left: 10px; | |
` | |
const TodoForm = props => { | |
const { handleSubmit, handleOnchangeInput, currentTodo } = props | |
return ( | |
<div> | |
<p>Enter your todo and hit the Enter key </p> | |
<form onSubmit={handleSubmit}> | |
<FormInput placeholder="Enter new todo" onChange={handleOnchangeInput} value={currentTodo} /> | |
</form> | |
</div> | |
) | |
} | |
TodoForm.defaultProps = { | |
currentTodo: '', | |
handleSubmit: () => {}, | |
handleOnchangeInput: ()=>{} | |
} | |
TodoForm.propTypes = { | |
currentTodo: PropTypes.string, | |
handleSubmit: PropTypes.func, | |
handleOnchangeInput: PropTypes.func | |
} | |
export default TodoForm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment