-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Issue Report
Front-end: Examine Select-all Behavior in FacilitiesMultiSelect.js
Expected behavior
Behavior could be as expected, but worth examining for possible performance improvements.
Actual behavior
src/components/FacilitiesMultiSelect.js
-
Inside the useEffect, you are checking the length of facilities against the length of
selected facilities to determine if "Select All" should be on or off. In this case, the
selectedFacilities dependency could potentially cause frequent re-renders. -
The code block: selectedFacilities.indexOf(id) > -1 inside the map function
can be performance-intensive if there are many facilities since indexOf would be O(n). -
The "Select All" option toggles the state, which means if all facilities are already selected
and a user clicks "Select All" again, it will deselect all. If this is the desired behavior, it's
okay. If not, you might want to address it.