Skip to content

Commit 3523734

Browse files
committed
selectors
1 parent 583015b commit 3523734

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ function doSetFilter(filter) {
9393
};
9494
}
9595

96+
// selectors
97+
98+
function getTodosAsIds(state) {
99+
return state.todoState.ids;
100+
}
101+
102+
function getTodo(state, todoId) {
103+
return state.todoState.entities[todoId];
104+
}
105+
96106
// store
97107

98108
const rootReducer = combineReducers({
@@ -144,13 +154,13 @@ function TodoItem({ todo, onToggleTodo }) {
144154

145155
function mapStateToPropsList(state) {
146156
return {
147-
todosAsIds: state.todoState.ids,
157+
todosAsIds: getTodosAsIds(state),
148158
};
149159
}
150160

151161
function mapStateToPropsItem(state, props) {
152162
return {
153-
todo: state.todoState.entities[props.todoId],
163+
todo: getTodo(state, props.todoId),
154164
};
155165
}
156166

0 commit comments

Comments
 (0)