1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-26 10:43:35 +02:00

Sample React-Express-MongoDB (#59)

Signed-off-by: Afzal <sah.afzal@gmail.com>
This commit is contained in:
Syed Afzal 2020-05-12 00:40:39 +05:00 committed by GitHub
parent 3599a2e685
commit 2f750eb4f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 18779 additions and 0 deletions

View file

@ -0,0 +1,22 @@
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>
)
}
}

View file

@ -0,0 +1,48 @@
import React from 'react';
export default class TodoList extends React.Component {
constructor(props){
super(props);
this.state = {
activeIndex:0,
}
}
_handleActive(index) {
this.setState({
activeIndex: index
})
}
_renderTodos(todos) {
return (
<ul className="list-group">
{
todos.map((todo, i) => {
return (<li className={'list-group-item cursor-pointer ' + (i===this.state.activeIndex ? 'active' : '')}
key={i}
onClick={() => {this._handleActive(i)}}
>
{todo.text}
</li>)
})
}
</ul>
)
}
render() {
let { todos } = this.props;
return (
todos.length > 0 ?
this._renderTodos(todos)
:
<div className="alert alert-primary" role="alert">
No Todos to display
</div>
)
}
}