Reputation: 369
I want to deploy my react app with subpath (subdirectory path) but I don't want to set the subdirectory/path name in react app as this subdirectory name may change in future.
How to make configuration at react app level as it can work for any subdirectory name at server side which will not be hardcoded at react app level and it will be as a subpath for the application url.
eg. https://www.dummyname.com/anysubpath
Upvotes: 5
Views: 574
Reputation: 848
You can create a reusable HOC and handle the logic of the server data in that and pass it to the path
property in react-router.
For a dynamic path (slug) use dynamic routes like below:
<Route path="/some-path/:slug" component={SomeComponent} />
For more details refer to React router dynamic routing
Upvotes: 1