Skip to content

Commit 6ff5577

Browse files
committed
connecting everywhere
1 parent 3662ad1 commit 6ff5577

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/index.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,16 @@ const store = createStore(rootReducer);
8989

9090
// view layer
9191

92-
function TodoApp({ todos, onToggleTodo }) {
93-
return <TodoList
94-
todos={todos}
95-
onToggleTodo={onToggleTodo}
96-
/>;
92+
function TodoApp() {
93+
return <ConnectedTodoList />;
9794
}
9895

99-
function TodoList({ todos, onToggleTodo }) {
96+
function TodoList({ todos }) {
10097
return (
10198
<div>
102-
{todos.map(todo => <TodoItem
99+
{todos.map(todo => <ConnectedTodoItem
103100
key={todo.id}
104101
todo={todo}
105-
onToggleTodo={onToggleTodo}
106102
/>)}
107103
</div>
108104
);
@@ -135,11 +131,12 @@ function mapDispatchToProps(dispatch) {
135131
};
136132
}
137133

138-
const ConnectedTodoApp = connect(mapStateToProps, mapDispatchToProps)(TodoApp);
134+
const ConnectedTodoList = connect(mapStateToProps)(TodoList);
135+
const ConnectedTodoItem = connect(null, mapDispatchToProps)(TodoItem);
139136

140137
ReactDOM.render(
141138
<Provider store={store}>
142-
<ConnectedTodoApp />
139+
<TodoApp />
143140
</Provider>,
144141
document.getElementById('root')
145142
);

0 commit comments

Comments
 (0)