Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AddTodo from '../components/AddTodo'
import TodoList from '../components/TodoList'
import Footer from '../components/Footer'
import { memoize, createMemoizedFunction } from '../memoize'
import { createStructuredSelector } from 'reselect';

function selectTodos(todos, filter) {
console.log("Recalculating selectTodos");
Expand Down Expand Up @@ -75,15 +76,15 @@ App.propTypes = {
]).isRequired
}

// Which props do we want to inject, given the global state?
// Note: use https://github.com/faassen/reselect for better performance.
function select(state) {
return {
todos: state.todos,
visibilityFilter: state.visibilityFilter,
currentTheme: state.currentTheme
}
}
const todosSelector = state => state.todos;
const visibilityFilterSelector = state => state.visibilityFilter;
const currentThemeSelector = state => state.currentTheme;

const select = createStructuredSelector({
todos: todosSelector,
visibilityFilter: visibilityFilterSelector,
currentTheme: currentThemeSelector
});

// Wrap the component to inject dispatch and state into it
export default connect(select)(App)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"react": "^0.14.0",
"react-dom": "^0.14.0",
"react-redux": "^4.0.0",
"redux": "^3.0.0"
"redux": "^3.0.0",
"reselect": "^2.0.0"
},
"devDependencies": {
"babel-core": "^5.6.18",
Expand Down