Dhika Dhika - 6 months ago 81
React JSX Question

react router public path url

From all tutorial I read they use and setting react-router with "/" for their route path and http://mysite.or/ as their domain. what if I want "http://mysite.or/something" for my base path (home). Do I just need to change(add) the "/" on react-router to become "/something". or is there a proper way to do this?


Yes, if you use path as "/something" for parent Route component then /something will be the base path. But it would be better to use "/" at the parent and you create a subparent Route component with base path "/something"

<Route path="/">
  <Route path="/something">
     //Put routes that needs base path as /something/...