ER: Updating Pin's react class components to functional components (Performance)
Emergent Requirement - Updating the map Pins for better performance
- We want to update the map Pins code from class components to functional components to see if this will make the application more performant.
Relevant Issue(s)
- https://github.com/hackforla/311-data/issues/1865
Date discovered
- 2/3/25
Did this require a temporary workaround? If yes, what was it?
- N
Who was involved
- @efrenmarin45 @ryanfchase @traycn
What happens if this is not addressed
- The app continues to work, but will still apply the Pins logic in class component.
Resources
- Redux Docs: (Using Saga Helpers)
- Mozilla Docs: function*
- React Docs: Migrating from a PureComponent class component to a function
Recommended Action Items
- [x] Share issue link with team Lead
- [ ] Add to upcoming agenda
Potential Solutions
- Update the following files:
components/maps/index.js (L500)andredux/reducers/data.js
Dependency on ticket: https://github.com/hackforla/311-data/issues/1865
I'd like to wait and see how the application loads with the two class components migrating to functional components before we start migrating more class components.
From our discussion in our meeting about the conversion. This is from the react docs on React's recommendation for using components over classes.
From our discussion in our meeting about the conversion. This is from the react docs on React's recommendation for using components over classes.
Thank you @efrenmarin45, I've added the link you provide into the Resources section of the main ticket. I will hide these comments by the upcoming general meeting.
Looking into this file by file, leaving comments as I go along. Should have an update by our next meeting on 8/13/25.
Looking into this file by file, leaving comments as I go along. Should have an update by our next meeting on 8/13/25.
@efrenmarin45 just to clarify, you are providing an assessment on level of work required to migrate all components that manage any SR data (aka Pins) to functional components, correct? Or are you more generally assessing migrating all components. Either is fine, but I wanted to double check.
That being said, I think only the <Map/> and <MapContainer/> classes rely on SR data being passed as props. But migrating them to functional surely warrants more preparation. Let me know if that's your assessment as well.
For extra credit, let's discuss with the team about how SR data is managed by Redux Sagas (iirc that's how <Map/> receives the SR data into props). I'll make sure I have this prepped, reach out if you want to discuss anything further.
I also just realized that we have a ticket for reviewing all components. Perhaps you'd like to assign yourself to this ticket and move to in-progress. Sorry, I haven't been very clear on whether Emergent Requests are "pick-up-able". Here's the ticket:
- https://github.com/hackforla/311-data/issues/1988
@ryanfchase I think your suggestion would be a better option. I'll assign myself to #1988 and move to in progress. I'll be doing a full assessment of all the applicable files and proposing options so we can discuss as a team.