React-router <Link> not working with data-toggle

Viewed 1534

I am trying to use React, React-Router, and bootstrap to define a pill-based navigation bar. I define the nav bar like this:

render: function() {
  return (
    <div className="container-fluid">
      <ul className="nav nav-pills">
        <li className="active"><Link data-toggle="tab" to="/test/vocabulary">Vocabulary</Link></li>
        <li><Link data-toggle="tab" to="/test/noun">Noun</Link></li>
      </ul>
      <div className="tab-content">
        <div id="vocabulary" className="tab-pane fade in active">
          <TestVocabularyView/>
        </div>
        <div id="noun" className="tab-pane fade">
          <TestNounView/>
        </div>
      </div>
    </div>
  );
}

The problem I'm having is with the "data-toggle" aspect of the <Link>. When I click on the pill header, I see this in the browser console:

jquery.js:1491 Uncaught Error: Syntax error, unrecognized expression:
#/test/nounSizzle.error @ jquery.js:1491Sizzle.tokenize @
jquery.js:2108Sizzle.select @ jquery.js:2512Sizzle @    
jquery.js:888jQuery.fn.extend.find @ jquery.js:2728jQuery.fn.init @ 
jquery.js:2845jQuery @ jquery.js:73Tab.show @ bootstrap.js:2096(anonymous function) @ bootstrap.js:2169jQuery.extend.each @ 
jquery.js:384jQuery.fn.jQuery.each @ jquery.js:136Plugin @ 
bootstrap.js:2164clickHandler @ bootstrap.js:2193jQuery.event.dispatch @ 
jquery.js:4665elemData.handle @ jquery.js:4333

My routes are setup like this:

<Route path="test" component={TestView}>
  <Route path="vocabulary" component={TestVocabularyView}/>
  <Route path="noun" component={TestNounView}/>
</Route>

When I hover the mouse over the "Noun" pill header, I see this URL: http://localhost:3000/#/test/noun

I am using browserHistory.

1 Answers

Instead of doing

<li><Link data-toggle="tab" to="/test/noun">Noun</Link></li>

I did this:

<li data-toggle="tab"><Link to="/test/noun">Noun</Link></li>
Related