Skip to content

Instantly share code, notes, and snippets.

@lomse
Last active October 20, 2018 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lomse/bf335032afeef111115f2fc5126c54b9 to your computer and use it in GitHub Desktop.
Save lomse/bf335032afeef111115f2fc5126c54b9 to your computer and use it in GitHub Desktop.
TodoForm.jsx to add new todos
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