Created
June 29, 2016 18:19
-
-
Save egeste/0e3447664f3024384f2625ecebf02788 to your computer and use it in GitHub Desktop.
Working with react-bootstrap/react-router
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
// 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