This commit is contained in:
Oleg Silkin 2020-01-13 16:55:28 -05:00
commit c0db949a53
7 changed files with 53 additions and 38 deletions
src/redux/selectors

View file

@ -1,26 +1,32 @@
import { createSelector } from 'reselect';
export const selectState = (state) => state.notifications || {};
export const selectState = state => state.notifications || {};
export const selectToast = createSelector(selectState, (state) => {
if (state.toasts.length) {
const { id, params } = state.toasts[0];
return {
id,
...params,
};
export const selectToast = createSelector(
selectState,
state => {
if (state.toasts.length) {
const { id, params } = state.toasts[0];
return {
id,
...params,
};
}
return null;
}
);
return null;
});
export const selectError = createSelector(
selectState,
state => {
if (state.errors.length) {
const { error } = state.errors[0];
return {
error,
};
}
export const selectError = createSelector(selectState, (state) => {
if (state.errors.length) {
const { error } = state.errors[0];
return {
error,
};
return null;
}
return null;
});
);