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
Link: Make active
class configurable
#86
Comments
|
Agree with @spicyj. It's situations like these that var CustomLink = React.createClass({
getDefaultProps: function () {
return { activeClassName: 'custom-active-classname' };
},
render: function () {
return this.transferPropsTo(
<Link>{this.props.children}</Link>
);
}
}); |
just looked at our code and didn't realize we had that as a default prop, fantastic. |
@mjackson @ryanflorence It looks like Found some good docs at https://gist.github.com/sebmarkbage/a6e220b7097eb3c79ab7 but wasn't able to make the example (overwriting |
This is equivalent to what @mjackson said: var CustomLink = React.createClass({
getDefaultProps: function () {
return { activeClassName: 'custom-active-classname' };
},
render: function () {
return <Link {...this.props}>{this.props.children}</Link>;
}
}); If you want var CustomLink = React.createClass({
render: function () {
return (
<Link {...this.props} activeClassName="custom-active-classname">
{this.props.children}
</Link>
);
}
}); |
@spicyj Thanks, that works beautifully! |
* Router functionality * Custom active class - thanks to @spicyj - remix-run/react-router#86 * Update deps * Namespace CSS * Remove learn modules
Link.activeClassName = "somethingElse"
and
<Link activeClassName="somethingElse"/>
The text was updated successfully, but these errors were encountered: