Here's a simple practice for maintainable code
Here's a simple practice for maintainable code.
Separate these three activities:
1. Get data
2. Reformat data
3. Display data
Code that separates these concerns tends to be easier to understand, reuse, and maintain.
An example:
1. Get data: https://github.com/coryhouse/pluralsight-redux-app-used-to-build-script/tree/master/src/api
2. Format response: https://github.com/coryhouse/pluralsight-redux-app-used-to-build-script/blob/master/src/api/apiUtils.js#L1
3. Display data: https://github.com/coryhouse/pluralsight-redux-app-used-to-build-script/blob/master/src/components/courses/CourseList.js#L5
This way, each piece is simple and reusable. 👍
(this code is from my React and Redux course on Pluralsight)