Skip to content

Instantly share code, notes, and snippets.

@thomasboyt
Created February 19, 2016 21:10
Show Gist options
  • Save thomasboyt/550ed7949d4e4644ce2e to your computer and use it in GitHub Desktop.
Save thomasboyt/550ed7949d4e4644ce2e to your computer and use it in GitHub Desktop.
// How to pass arbitrary arguments to reselect selectors (I think?)
// arbitrary selector to capitalize a todo's name for... some reason
// memoized based on the todo object
const selector = createSelector(
(state, props) => state.todos.get(props.id),
(todo) => todo.title.toUpperCase()
);
const TodoTitle = React.createClass({
propTypes: {
todoId: React.PropTypes.number.isRequired,
},
render() {
return this.props.title;
}
});
function select(state, props) {
return {
title: selector(state, {
id: props.todoId
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment