Replies: 1 comment 3 replies
-
I'm having a similar code duplication across my project, especially since we are using a lot of overlays & modals that have a route. More specifically, we are having two Pages that both show a table of items where users can perform the same actions. This leads to having a lot of duplicate routes, which is basically not a problem for me, but I wasn't sure whats the best way not to write the same route definition over and over again <Routes>
<Route element={<ToolsPage />} path="tools">
<Route element={<RoutedOverlay />} path="overlay">
<Route element={<EditMasterdata />} path={EditMasterdata.Route} />
<Route element={<InstanceOverlay />} path={InstanceOverlay.Route} />
</Route>
</Route>
<Route element={<ServiceOrdersPage />} path="service-orders">
<Route element={<RoutedOverlay />} path="overlay">
<Route element={<EditMasterdata />} path={EditMasterdata.Route} />
<Route element={<InstanceOverlay />} path={InstanceOverlay.Route} />
</Route>
</Route>
</Routes>;
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
In my SPA React app I have a group of
Route
s that relate to particular business logic, for example a payment flow:I want to reuse same routes in a tiny-bit different context (different callbacks, Layout wrapper etc.). And I dont want to copy-paste all 10ish routes like this:
This flowing solution works for me:
But my gut tells me its a mistake and there is a better way to do it.
I didn't find any similar cases, so may be I have the overall wrong approach for this kind of code reuse in React?
Beta Was this translation helpful? Give feedback.
All reactions