-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed unnecessary className on Link #3288
Conversation
LGTM 👍 |
@@ -119,7 +118,7 @@ const Link = React.createClass({ | |||
if (activeClassName || (activeStyle != null && !isEmptyObject(activeStyle))) { | |||
if (router.isActive(location, onlyActiveOnIndex)) { | |||
if (activeClassName) | |||
props.className += props.className === '' ? activeClassName : ` ${activeClassName}` | |||
props.className = `${props.className || ''} ${activeClassName}`.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any harm to just pulling in classnames
here? I can't imagine anybody doesn't have classnames
already installed, so this should dedupe trivially.
Otherwise IMO this is better written as:
if (activeClassName) {
if (props.className) {
props.className += ` ${activeClassName}`
} else {
props.className = activeClassName
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. We can do that after merge. For now, this gets the job done and adds a test so any further fixes are easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used a className in a while.
👍 |
LGTM as well, then. Thanks! |
I don't use class names in react-boilerplate, I've never had a good use for it. (sorry @JedWatson!) I wouldn't go assuming everybody has it installed! |
<Link />
always adds theclass=""
attribute even when it's not defined or is active. When you do server rendering you don't want unnecessary attributes.