Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active October 8, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/a7381a3f3b41547117ae3c130374d2f8 to your computer and use it in GitHub Desktop.
Save productioncoder/a7381a3f3b41547117ae3c130374d2f8 to your computer and use it in GitHub Desktop.
Using Reselect in a Redux project
import {createSelector} from 'reselect';
export default function (state = {}, action) {
switch (action.type) {
case UPDATE_FIRST_NAME:
return {
...state,
firstName: action.firstName
};
case UPDATE_LAST_NAME:
return {
...state,
firstName: action.lastName
};
default:
return state;
}
}
export const getFullName = createSelector(
(state) => state.firstName,
(state) => action.lastName,
(firstName, lastName) => [firstName,lastName].join(' ')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment