Created
February 21, 2017 04:48
-
-
Save alex35mil/71b5e19e3e764838ffa3b8bd92954ebe to your computer and use it in GitHub Desktop.
Common mistakes in redux parts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const selectEntity = entityId => ({ | |
type: ENTITY_SELECT, | |
entityId, | |
}); | |
const onEntitySelect = { | |
[ENTITY_SELECT]: (state, { id }) => state.set('id', id), | |
// ^ | |
// oops, `entityId` was dispatched | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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` | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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