UNPKG

react-bootstrap

Version:

Bootstrap 3 components build with React

55 lines (46 loc) 1.22 kB
"use strict"; /** @jsx React.DOM */ var React = require("./react-es6")["default"]; var classSet = require("./react-es6/lib/cx")["default"]; var BootstrapMixin = require("./BootstrapMixin")["default"]; var NavItem = React.createClass({displayName: 'NavItem', mixins: [BootstrapMixin], propTypes: { onSelect: React.PropTypes.func, active: React.PropTypes.bool, disabled: React.PropTypes.bool, href: React.PropTypes.string, title: React.PropTypes.string }, getDefaultProps: function () { return { href: '#' }; }, render: function () { var classes = { 'active': this.props.active, 'disabled': this.props.disabled }; return this.transferPropsTo( React.DOM.li( {className:classSet(classes)}, React.DOM.a( {href:this.props.href, title:this.props.title, onClick:this.handleClick, ref:"anchor"}, this.props.children ) ) ); }, handleClick: function (e) { if (this.props.onSelect) { e.preventDefault(); if (!this.props.disabled) { this.props.onSelect(this.props.key,this.props.href); } } } }); exports["default"] = NavItem;