import React from 'react'; import { observable, action, makeObservable } from 'mobx'; import { PropTypes } from 'mobx-react'; import { Layout } from './shared/Layout'; import 'bootstrap/dist/css/bootstrap.min.css'; interface ToDoListItem { todo: string, checked: boolean, } interface ToDoState { inputText: string, toDoList: ToDoListItem[], } const TodoItem: React.FunctionComponent<{ item: ToDoListItem, onRemoveButtonClick: (id) => void }> = ({ item, onRemoveButtonClick }) => { let onClick = () => { onRemoveButtonClick(item); } return (
{item.todo}
); } const TodoList: React.FunctionComponent<{ items: ToDoListItem[], onChange?: (item) => void }> = ({ items, onChange }) => { const onRemoveButtonClick = (item) => { if(onChange) { onChange(item); } } const listItems = items.map(Q => ) return
{listItems}
; } class Todo extends React.Component<{},ToDoState> { constructor(props) { super(props); this.state = { inputText: "", toDoList: [], }; } onTextInput = (e: React.ChangeEvent) => { this.setState({ inputText: e.target.value, }) }; onChange = (item) => { this.setState( { toDoList: this.state.toDoList.filter(x => item.todo != x.todo) } ) }; addList = () => { this.setState({ inputText: "", toDoList: [...this.state.toDoList, { todo: this.state.inputText, checked: false }], }) } render() { return (
{this.state.inputText}
); } } export default () => { return }