John John - 1 year ago 145
React JSX Question

how to add slash in react router path

I have developed a page with react whose route is


When the url is loaded I need to append a slash at the end of the url like this


My Routes are like this

Router history={browserHistory}>
<Route path='/' component={Home} />
<Route path='/page1' component={Page1} />

I tried to change the path directly to "/page1/" instead of "/page1" but this will not load
, It will open only

I want both the path to load the Page1 component

Answer Source

According to this reply,

Using hooks (onEnter and onChange) with react-router v2 or above may achieve what you need.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download