diff --git a/examples/todoapp/components/TodoApp.js b/examples/todoapp/components/TodoApp.js
index 2d565b87..ab3aca07 100644
--- a/examples/todoapp/components/TodoApp.js
+++ b/examples/todoapp/components/TodoApp.js
@@ -1,20 +1,20 @@
import { TodoItem } from "./TodoItem.js";
-const { StoreMixin, Component } = odoo.core;
+const { connect, Component } = odoo.core;
const ENTER_KEY = 13;
-export class TodoApp extends StoreMixin(Component) {
+function mapStateToProps(state) {
+ return { todos: state.todos };
+}
+
+class TodoApp extends Component {
template = "todoapp";
widgets = { TodoItem };
state = { filter: "all" };
- get todos() {
- return this.env.store.state.todos;
- }
-
get visibleTodos() {
- let todos = this.todos;
+ let todos = this.props.todos;
if (this.state.filter === "active") {
todos = todos.filter(t => !t.completed);
}
@@ -25,11 +25,11 @@ export class TodoApp extends StoreMixin(Component) {
}
get allChecked() {
- return this.todos.every(todo => todo.completed);
+ return this.props.todos.every(todo => todo.completed);
}
get remaining() {
- return this.todos.filter(todo => !todo.completed).length;
+ return this.props.todos.filter(todo => !todo.completed).length;
}
get remainingText() {
@@ -54,3 +54,5 @@ export class TodoApp extends StoreMixin(Component) {
this.env.store.dispatch("toggleAll", !this.allChecked);
}
}
+
+export default connect(mapStateToProps)(TodoApp);
diff --git a/examples/todoapp/main.js b/examples/todoapp/main.js
index 0e77fe0d..342511b7 100644
--- a/examples/todoapp/main.js
+++ b/examples/todoapp/main.js
@@ -1,4 +1,4 @@
-import { TodoApp } from "./components/TodoApp.js";
+import TodoApp from "./components/TodoApp.js";
import { makeStore } from "./store.js";
async function makeEnv() {
diff --git a/examples/todoapp/templates.xml b/examples/todoapp/templates.xml
index dd444b50..a2290c86 100644
--- a/examples/todoapp/templates.xml
+++ b/examples/todoapp/templates.xml
@@ -8,7 +8,7 @@
-