score:0

// locationsSlice.js

import { createSelector } from "@reduxjs/toolkit";

// ...

const selectForecasts = (state) => state.locations.forecasts;
const favIds = (state) => state.user.favIds;

export const selectFavForecasts = createSelector(
  selectForecasts,
  favIds,
  (forecasts, ids) => {
    return forecasts.filter((forecast) => ids.includes(forecast.id));
  },
);

Related Query

More Query from same tag