In general, big from me to moving to a slimmer structure with less boilerplate. Glad to see the redux community has finally figured out a way of reducing the amount of files and boilerplate needed to use it I think the combination of hooks and slices actions can greatly simplify many components we have now that use the redux store (in addition to moving component-internal state out of the store, but that’s a separate discussion).
I also agree with reducing the number of tests that verify redux is working correctly and snapshots that often offer little value and make refactoring more difficult, although I think we already had this discussion and agreed to move to use react testing library.
A couple of notes/questions:
- In case all (or most) of what the
index.js
file does is export the component, do we actually need an additionalComponent.js
file? - We still have a few components that use the “old” rails convention, so that we didn’t even finish the migration from the previous convention to the current one. How do we approach this migration in a manner that allows us to complete it before a new convention arises and we have 3 different conventions instead of 2?
- With regards to helpers, I would suggest we only extract code to a
helpers.js
once the main file becomes too big to manage or there is some common logic that is repeated in multiple sub-components, as jumping back and forth between files makes following the data flow more difficult. - What about components that have sub-components which are used only by them? will they live in a subfolder inside the main component? in a subfolder for each subcomponent? in a separate file inside the main component folder?
- We might want to also reconsider the organization of the
react_app
folder itself, which could deserve a post of its own.
As a side note, I’ll mention the research that @Gwmngilfen did a few years ago, which indicated that a larger number of files in a PR correlated very well with the mean time-to-merge, even more than the number of lines changed. While correlation does not necessarily indicate causation, my personal experience as a reviewer certainly confirms that PRs with many files and lines changed take me a lot longer to review and tend to have a higher number of missed bugs. Anything that can reduce the amount of files needed to complete a feature/fix will likely also lead to easier reviews and faster merges.