Skip to content

Improvement: Simplify logic to populate and name entries in the platformList module #575

@naomatheus

Description

@naomatheus

we could simplify the logic that handles populating and renaming the platform lists on CASEI's Explore pages by having the translation of the group name occur within the usePlatformList hook itself. First identified in comments in #574

@alukach: we could simplify this by having the translation of the group name occur within the usePlatformList hook itself to reduce the number of files and functions in this project. Also an implementation like this will allow future consumers of usePlatformList to get the same results as what we are rendering in the ExplorePlatforms components:

const groupByPlatformType = (acc, item) => {
  const categoryTranslations = {
    Aircraft: "Air-based platforms",
  };

  const group =
    categoryTranslations[item.searchCategory] ?? item.searchCategory ?? "Other";

  (acc[group] ??= []).push(item);

  return acc;
};

In #574 this was attempted, but I encountered unexpected Render Lifecycle behavior:

  • After the first time the page renders, we then have more items pushed into the platform list. It gives correct results on the first render, but then on the second render the Air-based platforms are pushed to include 320 platforms (all platforms).

Metadata

Metadata

Assignees

No one assigned

    Labels

    maintenanceTickets that do not encompass new features but contribute to the overall quality of the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions