Conditional render of icon component
This commit is contained in:
parent
956816c4c7
commit
c6f883f88c
1 changed files with 7 additions and 1 deletions
|
@ -2,8 +2,14 @@ import React from 'react';
|
||||||
|
|
||||||
export default class Item extends React.Component {
|
export default class Item extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
let icon;
|
||||||
|
if (this.props.icon) {
|
||||||
|
icon = (
|
||||||
|
<i className={'icon ' + this.props.icon}></i>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<li><a href={this.props.href}><i className={'icon ' + this.props.icon}></i> {this.props.children}</a></li>
|
<li><a href={this.props.href}>{icon} {this.props.children}</a></li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue