Skip to content

Commit cf920ea

Browse files
committed
simplify the Tab example a bit
We can avoid the use of <IndexLink/> entirely, since it's just a simple wrapper around <Link/> that adds a single prop.
1 parent 011c339 commit cf920ea

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/API.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -594,21 +594,21 @@ React.createClass({
594594
Let's say you are using bootstrap and want to get `active` on those `li` tags for the Tabs:
595595

596596
```js
597-
import { Link, IndexLink, History } from 'react-router'
597+
import { Link, History } from 'react-router'
598598

599599
const Tab = React.createClass({
600600
mixins: [ History ],
601601
render() {
602-
const isActive = this.history.isActive(this.props.to, this.props.query, this.props.indexLink)
602+
const isActive = this.history.isActive(this.props.to, this.props.query, this.props.onlyActiveOnIndex)
603603
const className = isActive ? 'active' : ''
604-
const LinkElement = this.props.indexLink ? IndexLink : Link;
605-
return <li className={className}><LinkElement {...this.props}/></li>
604+
return <li className={className}><Link {...this.props}/></li>
606605
}
607606
})
608607

609-
// use it just like <Link/> or <IndexLink/>, and you'll get an anchor wrapped in an `li`
610-
// with an automatic `active` class on both.
611-
<Tab to="/" indexLink>Home</Tab>
608+
// Use it just like <Link/>, and you'll get an anchor wrapped in an `li` with
609+
// an automatic `active` class on both when appropriate. Add `onlyActiveOnIndex`
610+
// to trigger <IndexLink/> behavior.
611+
<Tab to="/" onlyActiveOnIndex>Home</Tab>
612612
<Tab to="about">About</Tab>
613613
<Tab href="foo">Foo</Tab>
614614
```

0 commit comments

Comments
 (0)