Skip to content

Instantly share code, notes, and snippets.

@alex35mil
Created February 21, 2017 04:48
Show Gist options
  • Save alex35mil/71b5e19e3e764838ffa3b8bd92954ebe to your computer and use it in GitHub Desktop.
Save alex35mil/71b5e19e3e764838ffa3b8bd92954ebe to your computer and use it in GitHub Desktop.
Common mistakes in redux parts
const selectEntity = entityId => ({
type: ENTITY_SELECT,
entityId,
});
const onEntitySelect = {
[ENTITY_SELECT]: (state, { id }) => state.set('id', id),
// ^
// oops, `entityId` was dispatched
};
// form state has `id` property
const formState = {
id: null,
};
const onEntitySelect = {
[UPDATE]: (state, { entityId }) => state.set('entityId', entityId),
// ^
// oops, state doesn't have `entityId`, but has `id`
};
// state has `id` property
const formState = {
id: null,
};
export const storeSelector = state => state.formStore;
export const idSelector = createSelector(
storeSelector,
store => store.get('entityId'),
// ^
// oops, state doesn't have `entityId`, but has `id`
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment