Created
February 12, 2016 14:02
-
-
Save codemilli/72f354730418c62f1a7f to your computer and use it in GitHub Desktop.
add new todo
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, { PropTypes } from 'react'; | |
/** | |
* Define React Presentational Component Add | |
*/ | |
const Add = ({ onSubmit }) => { | |
let input; | |
const submit = (e) => { | |
e.preventDefault(); | |
if (!input.value) return; | |
onSubmit(input.value); | |
input.value = ''; | |
}; | |
return ( | |
<form onSubmit={submit}> | |
<input type="text" ref={node => { | |
input = node | |
}} /> | |
<button type="submit">Submit</button> | |
</form> | |
); | |
}; | |
export default Add; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment