gajus / gajus/babel-plugin-react-css-modules
Passing multiple style props to a child component
- Lenguaje dominante
- JavaScript
- Estrellas
- 2k
- Forks
- 159
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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.
```
import styles from './some.css';
...
...
...
...
```
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?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
No se mencionan archivos, pruebas ni puntos de entrada. Empieza revisando cómo el plugin gestiona styleName y las importaciones con nombre de módulos CSS; después, comprueba la documentación y los ejemplos existentes para ver cómo se usan varias props de estilo. Se considera terminado cuando se haya identificado y documentado un enfoque claro y compatible, o cuando se haya definido el comportamiento solicitado si no existe compatibilidad.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, react
- Área
- frontend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 20/100