Skip to content

Instantly share code, notes, and snippets.

@lomse
Created October 20, 2018 10:18
Show Gist options
  • Save lomse/41723a1173bae08f88bd52cdd22f0863 to your computer and use it in GitHub Desktop.
Save lomse/41723a1173bae08f88bd52cdd22f0863 to your computer and use it in GitHub Desktop.
TodoForm.jsx with events
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 } = props
return (
<div>
<p>Enter your todo and hit the Enter key </p>
<form onSubmit={handleSubmit}>
<FormInput placeholder="Enter new todo" onChange={handleOnchangeInput} />
</form>
</div>
)
}
TodoForm.defaultProps = {
handleSubmit: () => {},
handleOnchangeInput: ()=>{}
}
TodoForm.propTypes = {
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