Sharing code between slices (forbidden) #822
-
Where should slices' shared code go?The documentation says that "there should be no code sharing in that folder.", speaking here about code shared inside a slice. I kind of understand why this rule exists. If we started having shared code on each and every nested folder, it would be really hard to navigate around. However, the documentation doesn't explain what's recommended in this very case.
Where should this code go? Let's say it's several UI components. I would have instinctively done the following:
I don't think I should put it in the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you need to share code between several features, it's usually a sign that there's something in common with these features, and perhaps it is worthwhile to merge them all into a single feature. Also it's worth noting that not every user action needs to be a separate feature — code that's only used on a single page should stay within that page. If the features are indeed very independent, but they need to reuse code, then that code should probably be moved down to Shared. |
Beta Was this translation helpful? Give feedback.
If you need to share code between several features, it's usually a sign that there's something in common with these features, and perhaps it is worthwhile to merge them all into a single feature. Also it's worth noting that not every user action needs to be a separate feature — code that's only used on a single page should stay within that page.
If the features are indeed very independent, but they need to reuse code, then that code should probably be moved down to Shared.