Skip to content
This repository has been archived by the owner on Dec 18, 2022. It is now read-only.

Commit

Permalink
added todo list
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanqian29 committed Feb 12, 2019
1 parent 806e842 commit 2c06c79
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 51 deletions.
74 changes: 54 additions & 20 deletions docs/pie7.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pie7.js.map

Large diffs are not rendered by default.

43 changes: 19 additions & 24 deletions src/js/TodoList.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
import { h, Component } from 'preact';

export default class TodoList extends Component {

constructor() {
super();
// state = { todos: [], text: '' };
this.state = { todos: [], text: '' };
this.setText = this.setText.bind(this)
this.addTodo = this.addTodo.bind(this)
}

setText(e) {
// this.setState({ text: e.target.value });
this.setState({ text: e.target.value });
};

addTodo() {
// let { todos, text } = this.state;
// todos = todos.concat({ text });
// this.setState({ todos, text: '' });
let { todos, text } = this.state;
todos = todos.concat({ text });
this.setState({ todos, text: '' });
};

render() {
// render({ }, { todos, text }) {
// return (
// <form onSubmit={this.addTodo} action="javascript:">
// <input value={text} onInput={this.setText} />
// <button type="submit">Add</button>
// <ul>
// { todos.map( todo => (
// <li>{todo.text}</li>
// )) }
// </ul>
// </form>
// );
return <div>Hello, world</div>;
render({ }, { todos, text }) {
return (
<form onSubmit={this.addTodo} action="javascript:">
<input value={text} onInput={this.setText} />
<button type="submit">Add</button>
<ul>
{ todos.map( todo => (
<li>{todo.text}</li>
)) }
</ul>
</form>
);
}

}


8 changes: 2 additions & 6 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,11 @@ document.createTextNode = function(data) {


import { h, render, Component } from 'preact';
// import TodoList from './TodoList.jsx';
import TodoList from './TodoList.jsx';


// const TodoList = props => <div>Hiya</div>;
class TodoList extends Component {
render(props, state) {
return <div>Hiya!</div>;
}
}



function begin(target) {
Expand Down

0 comments on commit 2c06c79

Please sign in to comment.