forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBreadcrumbItem.js
More file actions
50 lines (42 loc) · 1.09 KB
/
BreadcrumbItem.js
File metadata and controls
50 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import classNames from 'classnames';
import React from 'react';
import SafeAnchor from './SafeAnchor';
const propTypes = {
/**
* If set to true, renders `span` instead of `a`
*/
active: React.PropTypes.bool,
/**
* `href` attribute for the inner `a` element
*/
href: React.PropTypes.string,
/**
* `title` attribute for the inner `a` element
*/
title: React.PropTypes.node,
/**
* `target` attribute for the inner `a` element
*/
target: React.PropTypes.string,
};
const defaultProps = {
active: false,
};
class BreadcrumbItem extends React.Component {
render() {
const { active, href, title, target, className, ...props } = this.props;
// Don't try to render these props on non-active <span>.
const linkProps = { href, title, target };
return (
<li className={classNames(className, { active })}>
{active ?
<span {...props} /> :
<SafeAnchor {...props} {...linkProps} />
}
</li>
);
}
}
BreadcrumbItem.propTypes = propTypes;
BreadcrumbItem.defaultProps = defaultProps;
export default BreadcrumbItem;