forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f07c696
commit 85c699c
Showing
5 changed files
with
45 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# IsActive Mixin | ||
|
||
Provides `isActive` to a component. | ||
|
||
## Methods | ||
|
||
### `isActive(pathname, query)` | ||
|
||
Returns `true` or `false` depending on if the current path is active. | ||
Will be true for every route in the route branch matched by the | ||
`pathname` (child route is active, therefore parent is too). | ||
|
||
## Example | ||
|
||
Let's say you are using bootstrap and want to get `active` on those `li` | ||
tags for the Tabs: | ||
|
||
```js | ||
import { Link, IsActive } from 'react-router'; | ||
|
||
let Tab = React.createClass({ | ||
|
||
mixins: [ IsActive ], | ||
|
||
render() { | ||
let isActive = this.isActive(this.props.to, this.props.query); | ||
let 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> | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters