Skip to content

Commit

Permalink
added State mixin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanflorence committed Jun 10, 2015
1 parent bd6d2e9 commit 5f7d7e1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions doc/04 Mixins/State.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Mixes in the `isActive` method of `Router`.

Methods
-------

### isActive

See [router.isActive][router.isActive]

Example
-------

Let's say you are using bootstrap and want to get `active` on those `li`
tags for the Tabs:

```js
import { Link, State } from 'react-router';

var Tab = React.createClass({

mixins: [ State ],

render() {
var isActive = this.isActive(this.props.href, this.props.query);
var className = isActive ? 'active' : '';
return <li className={className}><Link {...this.props}/></li>;
}

});

// use it just like <Link/>, and you'll get an anchor wrapped in an `li`
// with an automatic `active` class on both.
<Tab href="foo">Foo</Tab>
```

[router.isActive]:#TODO

0 comments on commit 5f7d7e1

Please sign in to comment.