communityconnect icon indicating copy to clipboard operation
communityconnect copied to clipboard

Refactoring codes

Open Khoawala opened this issue 8 years ago • 4 comments

I think app.js is getting pretty long and will be hard to read for newcomers. Can we refactor this with some javascript structure standard that I'm not aware of?

Khoawala avatar Oct 07 '18 16:10 Khoawala

I have made some basic changes to the App.js file to improve readability and separated some logic out to other files where possible. I think we will want to move the callSheets and normalizeHeaders functions to a separate file at some point, which would help clarify and shorten the app.js file.

I have been looking at how to handle state, perhaps we can use the React Context API instead of adding the overhead of Redux. I think the Map component could be a good candidate to handle its own state, and this would allow us to move several functions (onMouseEnter, onMouseLeave, possibly onOrganizationClick) out of App.js entirely. I am wary of moving the state management until I learn more about the best practices for state handling.

If anyone has an opinion on any of this please let me know. I will continue researching state management for now

DavidNoftsier avatar Oct 11 '18 16:10 DavidNoftsier

Can you make a pull request with what you have? I want to refactor some components. I've separated the Header into smaller components so avoid the Header.js file to avoid merge conflicts.

Khoawala avatar Oct 15 '18 03:10 Khoawala

Absolutely @Khoawala, I just made a pull request (#71 ) with what I have

DavidNoftsier avatar Oct 15 '18 13:10 DavidNoftsier

The to do list is as follows for refactoring App.js

  • [x] Refactor JSX structures for readability

  • [x] Move callSheets logic to separate file

  • [x] Move normalizeHeaders logic to separate file

  • [x] Consolidate map related state handling and logic to exist in the Map component

  • [x] Move sorting and ResultList related state handling and logic to ResultList component

  • [ ] Move location related logic to utility file or Map component

  • [ ] Move components to individual folders

DavidNoftsier avatar Oct 25 '18 18:10 DavidNoftsier