chobo2 chobo2 - 1 year ago 269
React JSX Question

How to Ignore Links in React Router?

I am trying to implement react router into my app but I am running into a issue where I have some "links" that display "modal" dialogs but react router is treating them as routes and sending me back to my "home" page

<a href="#" onClick={() => this.props.Show(true) }><i className="fa fa-plus" aria-hidden="true">


<Provider store={store}>
<Router history={hashHistory}>
<Route path="/" component={Layout}>
<IndexRoute component={Home}></IndexRoute>
<Route path="app" name="app" component={App}></Route>

That link is in a component in the "App" component.

Answer Source

If you want prevent an anchor tag from navigating, it is recommended that you add


to your onClick event handler.

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