Skip to content

Instantly share code, notes, and snippets.

@codemilli
Created February 12, 2016 14:02
Show Gist options
  • Save codemilli/72f354730418c62f1a7f to your computer and use it in GitHub Desktop.
Save codemilli/72f354730418c62f1a7f to your computer and use it in GitHub Desktop.
add new todo
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