Skip to content
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

doesn't work properly with react-css-modules #498

Closed
mqklin opened this issue Jan 10, 2017 · 10 comments
Closed

doesn't work properly with react-css-modules #498

mqklin opened this issue Jan 10, 2017 · 10 comments
Labels

Comments

@mqklin
Copy link

mqklin commented Jan 10, 2017

demo

Only inner styleName compiles to 'class', but inners not. You can see that div-2 value has stylename attribute, but should class as div-1.
1


Component code:

import React, { Component } from 'react';
import CSSModules from 'react-css-modules';
import styles from './styles.css';

@CSSModules(styles)
export default class App extends Component {
  render() {
    return (
      <div styleName="div-1">
        <div styleName="div-2">
          Big square should be red; <br /> Small square should be black.
        </div>
      </div>
    );
  }
}

styles.css:

.div-1 {
  width: 500px;
  height: 500px;
  background: red;
}

.div-2 {
  width: 200px;
  height: 200px;
  background: black;
  color: white;
}


How it looks:
1

How it should:
1

@developit developit changed the title doesn't work properly with css-modules doesn't work properly with react-css-modules Jan 10, 2017
@developit
Copy link
Member

@mkxml seems like he is using preact-compat - I was looking through the react-css-modules source to see if I could find where they're doing the VNode manipulation. Maybe just an issue with vnode.props being non-enumerable?

@mkxml
Copy link
Collaborator

mkxml commented Jan 10, 2017

@developit Hmm, with preact-compat it should work. After some consideration I removed my comment since it wouldn't help in this case. It would be useful if it was preact core + css-modules.

@developit
Copy link
Member

indeed - your comment is how I use CSS modules too 👌

@mqklin
Copy link
Author

mqklin commented Jan 10, 2017

It's very verbose to write styles every time, css-modules allows to write it only once, that's why I use it. Will be very great for me if this will be fixed, I want to try preact in production. Thanks.

@developit
Copy link
Member

@mqklin understandable! This will likely be solved over in preact-compat, but I'm fine tracking it here to avoid lots of issue juggling.

@mqklin
Copy link
Author

mqklin commented Feb 11, 2017

Any progress on this issue? Maybe I should create the issue in react-css-modules repo?

@developit
Copy link
Member

@mqklin Might be useful - link me in there so maybe we can get more context. I'm not super familiar with react-css-modules, so any help is very much appreciated!

@mqklin
Copy link
Author

mqklin commented Mar 5, 2017

I've migrated to styled-component. I don't think someone needs this issue to be fixed, so I'm closing it.

@mqklin mqklin closed this as completed Mar 5, 2017
@pavelivanov
Copy link

so sad, hoped it to be fixed... =/

@evenfrost
Copy link

@developit maybe it could get a bit of attention for upcoming release of Preact X? I know this issue was a kind of dead-end, but I'm ready to help if had some clues where to start (have a little to no experience in Preact/Babel plugins development).

Currently react-css-modules moved to babel-plugin-css-modules, and here is corresponding issue in its repo: gajus/babel-plugin-react-css-modules#250.

As for me, this is real helper in React project as you can switch from writing className={styles.foo} to just styleName="foo", and would be awesome to use it in Preact projects as well.

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

No branches or pull requests

5 participants