Skip to content

Commit

Permalink
Use class set for generating <Link> className
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Oct 10, 2014
1 parent bd23312 commit 0cf3d56
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/components/Link.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var React = require('react');
var classSet = require('react/lib/cx');
var merge = require('react/lib/merge');
var ActiveState = require('../mixins/ActiveState');
var Navigation = require('../mixins/Navigation');
Expand Down Expand Up @@ -80,12 +81,15 @@ var Link = React.createClass({
* the value of the activeClassName property when this <Link> is active.
*/
getClassName: function () {
var className = this.props.className || '';
var classNames = {};

if (this.props.className)
classNames[this.props.className] = true;

if (this.isActive(this.props.to, this.props.params, this.props.query))
className += ' ' + this.props.activeClassName;
classNames[this.props.activeClassName] = true;

return className;
return classSet(classNames);
},

render: function () {
Expand Down

0 comments on commit 0cf3d56

Please sign in to comment.