You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a child component, which accepts multiple props for styles, one for the container, and other for one of the internal elements. Generally, I would just name them something like className and elementClassName, and get different css classes from the parent in each of the props. With react-css-modules though, since the default rule only allows converting styleName to className, I can not pass different local classes in multiple props, as i can only have 1 styleName prop.
One of the way around this seems to be to use named imports instead of anonymous imports and then pass styles.containerClass in className and styles.elementClass in elementClassName prop. This does not require using the styleName prop at all.
This seems alright, and the other existing styleName in the file do not break, still work alright and do not need to be changed to styles.soemthing, but it is slightly confusing that the named import is being only used at one place, and at the rest of the places the anonymous string value in styleName still works fine.
Is there another preferred / prescribed approach to handle the above scenario?
The text was updated successfully, but these errors were encountered:
I have a child component, which accepts multiple props for styles, one for the container, and other for one of the internal elements. Generally, I would just name them something like
className
andelementClassName
, and get different css classes from the parent in each of the props. Withreact-css-modules
though, since the default rule only allows convertingstyleName
toclassName
, I can not pass different local classes in multiple props, as i can only have 1styleName
prop.One of the way around this seems to be to use named imports instead of anonymous imports and then pass
styles.containerClass
in className andstyles.elementClass
inelementClassName
prop. This does not require using thestyleName
prop at all.This seems alright, and the other existing
styleName
in the file do not break, still work alright and do not need to be changed tostyles.soemthing
, but it is slightly confusing that the named import is being only used at one place, and at the rest of the places the anonymous string value instyleName
still works fine.Is there another preferred / prescribed approach to handle the above scenario?
The text was updated successfully, but these errors were encountered: