Skip to content

Commit

Permalink
fix: remove state error when loading /recently route directly
Browse files Browse the repository at this point in the history
  • Loading branch information
shauke committed Apr 30, 2024
1 parent f2f5ebd commit 69f0caf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { addToRecently, clearRecently } from './recently.actions';

export type RecentlyViewedProducts = RecentlyViewedProduct[];

const initialState: RecentlyViewedProducts = [];
export const initialState: RecentlyViewedProducts = [];

export const recentlyReducer = createReducer(
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { isArrayEqual } from 'ish-core/utils/functions';

import { getRecentlyState } from '../recently-store';

import { RecentlyViewedProducts } from './recently.reducer';
import { RecentlyViewedProducts, initialState } from './recently.reducer';

const internalProducts = createSelector(getRecentlyState, state => state._recently);
const internalProducts = createSelector(getRecentlyState, state => state?._recently || initialState);

export const getRecentlyViewedProducts = createSelectorFactory<object, string[]>(projector =>
resultMemoize(projector, isArrayEqual)
Expand All @@ -21,7 +21,7 @@ export const getRecentlyViewedProducts = createSelectorFactory<object, string[]>
);

/**
* Selector to get the most recent 4 products without the currently viewed product on product detail pages
* Selector to get the most recent 12 products without the currently viewed product on product detail pages
*/
export const getMostRecentlyViewedProducts = createSelector(
getRecentlyViewedProducts,
Expand Down

0 comments on commit 69f0caf

Please sign in to comment.