Skip to content

Instantly share code, notes, and snippets.

@egeste
Created June 29, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egeste/0e3447664f3024384f2625ecebf02788 to your computer and use it in GitHub Desktop.
Save egeste/0e3447664f3024384f2625ecebf02788 to your computer and use it in GitHub Desktop.
Working with react-bootstrap/react-router
// A tab item
import React, {
Component,
PropTypes
} from 'react'
import {
Link,
withRouter
} from 'react-router'
@withRouter
export default class LinkedTab extends Component {
render() {
let { to, router } = this.props
let active = router.isActive(to, true)
let className = active ? 'active' : null
return (
<li className={ className }>
<Link { ...this.props }>
{ this.props.title }
</Link>
</li>
)
}
}
LinkedTab.propTypes = {
to: Link.propTypes.to,
router: PropTypes.object.isRequired
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment