Skip to content

Add custom attribute mapping feature #155

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

Merged
merged 4 commits into from
Feb 9, 2018
Merged

Conversation

yume-chan
Copy link
Contributor

I'm using this package with React Router. React Router has a <NavLink> component which has an activeClassName attribute, to be appended to its className when it's active.

However, I think it's extreme ugly when I can use styleName everywhere except here.

At first I want to extend the support to any attribute names ending with styleName/StyleName, but at last I added this attributeNames option to allow customization of the transformation. Each key represents a source attribute name and the corresponding value represents the destination attribute name. I think this feature can make it more easily to deal with components with multiple states, or with multiple xxxClassName attributes.

The default value is { "styleName": "className" } to keep backward compatibility, and the specified object will be merged with this default value unless it contains a different value for styleName.

A very rare (maybe just non-exist) use case will be setting styleName to something else or null. It just means the transformation process is totally controllable.

@gajus gajus merged commit e5b2d95 into gajus:master Feb 9, 2018
@gajus
Copy link
Owner

gajus commented Feb 9, 2018

Thank you

@ebramanti
Copy link

@gajus Can you run a release for this? Currently having to use my own branch for this feature.

@jus-jus
Copy link

jus-jus commented Apr 16, 2018

This feature is missing in my react-router setup. It would be great to have it without checking out @yume-chan branch.
Is it expected to have this one released soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants