Skip to content

Commit

Permalink
selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
rwieruch committed Jun 4, 2017
1 parent 583015b commit 3523734
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ function doSetFilter(filter) {
};
}

// selectors

function getTodosAsIds(state) {
return state.todoState.ids;
}

function getTodo(state, todoId) {
return state.todoState.entities[todoId];
}

// store

const rootReducer = combineReducers({
Expand Down Expand Up @@ -144,13 +154,13 @@ function TodoItem({ todo, onToggleTodo }) {

function mapStateToPropsList(state) {
return {
todosAsIds: state.todoState.ids,
todosAsIds: getTodosAsIds(state),
};
}

function mapStateToPropsItem(state, props) {
return {
todo: state.todoState.entities[props.todoId],
todo: getTodo(state, props.todoId),
};
}

Expand Down

0 comments on commit 3523734

Please sign in to comment.