awesome-compose/react-express-mongodb/frontend/src/components/AddTodo.js
Afzal a1153cea42 Sample React-Express-MongoDB
Signed-off-by: Afzal <sah.afzal@gmail.com>
2020-05-12 00:20:38 +05:00

22 lines
597 B
JavaScript

import React from 'react';
export default class AddTodo extends React.Component {
_onAddTodo = () => {
if(this.refs.todo.value.length > 0) {
this.props.handleAddTodo(this.refs.todo.value);
this.refs.todo.value = '';
}
};
render() {
return (
<div className="new-todo form-group">
<input type="text" className="form-control" ref="todo"/>
<button className="btn btn-primary" onClick={this._onAddTodo}>
Add Todo
</button>
</div>
)
}
}