Skip to content

Commit

Permalink
Make selectors return copy of messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dpikt committed Mar 20, 2018
1 parent b0d6fb9 commit 55afead
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const reducer = handleActions({
// Selectors
export const getFlashMessages = (state) => {
if (!state.flash) throw 'redux-flash: state not found. Did you remember to attach the reducer at key `flash`?'
return state.flash.messages
return [ ...state.flash.messages ]
}

export const getSuccessMessages = (state) => getFlashMessages(state).filter(m => !m.isError)
export const getErrorMessages = (state) => getFlashMessages(state).filter(m => m.isError)
export const getLatestMessage = (state) => [ ...getFlashMessages(state) ].pop()
export const getLatestMessage = (state) => getFlashMessages(state).pop()

0 comments on commit 55afead

Please sign in to comment.