Last active
August 29, 2015 14:19
-
-
Save dandean/6eaab3d79212cc61d9b1 to your computer and use it in GitHub Desktop.
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
const React = require('react'); | |
const { Link } = require('react-router'); | |
/** | |
* class ListItemLink < Router.Link | |
* | |
* Extends <Link /> to move the active class name to a wrapping <li> | |
*/ | |
export default class ListItemLink extends Link { | |
/** | |
* Moves the `style` and `className` props to a wrapping <li> element. | |
* Everything else is dropped down into a child <a> element. | |
*/ | |
render() { | |
let props = Object.assign({}, this.props, { | |
href: this.getHref(), | |
onClick: this.handleClick.bind(this) | |
}); | |
let style = {}; | |
if (props.activeStyle && this.getActiveState()) { | |
style = props.activeStyle; | |
} | |
return ( | |
<li className={this.getClassName()} style={style}> | |
<a {...props}>{this.props.children}</a> | |
</li> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment