babel-plugin-react-css-modules icon indicating copy to clipboard operation
babel-plugin-react-css-modules copied to clipboard

Unknown prop `styleName` on <div> tag.

Open Igor-Vuk opened this issue 8 years ago • 9 comments

Using version 2.6.1. I am getting this warning while testing the components.

Igor-Vuk avatar May 04 '17 23:05 Igor-Vuk

Is this "the same" issue as https://github.com/gajus/react-css-modules/issues/147?

tomasaschan avatar Jun 28 '17 07:06 tomasaschan

Also, I seem to be able to reproduce this with 3.0.0.

tomasaschan avatar Jun 28 '17 07:06 tomasaschan

@tlycken I was able to work around that issue in react-css-modules (it was something on my end causing the issue). However, switching from react-css-modules to this library, I'm greeted with this issue again.

besh avatar Jul 06 '17 19:07 besh

I just started to use ignore-styles library while testing components but that is not a good fix.

Igor-Vuk avatar Jul 06 '17 20:07 Igor-Vuk

@Igor-Vuk you might have to specify in your .babelrc file...

{
  "env": {
    "test": {
      "plugins": [
         ["react-css-modules", {
          "context": <same_context_as_your_webpack_config_context>
         }]
      ]       
    }
  }
}

besh avatar Jul 06 '17 21:07 besh

I tried to configure it the same way as is configured in my webpack, it didn't work.

"env": {
    "test": {
      "presets": [
        "react",
        "es2015",
        "stage-0"
      ],
      "plugins":[
        [ "babel-plugin-webpack-alias", { "config": "./webpack.config.js" } ],
        [ "babel-plugin-react-css-modules", {"context": "./src/client", "filetypes": {".scss": "postcss-scss"}}]
      ]
    }
  }

Igor-Vuk avatar Jul 06 '17 21:07 Igor-Vuk

I'm wondering if context gets resolved to a relative path under the hood or if it's expected that we pass in the resolved path.

besh avatar Jul 06 '17 21:07 besh

Digging through here, it doesn't look like it resolves an absolute path for the context you pass in.

besh avatar Jul 06 '17 21:07 besh

How should I write it then for it to work?

Igor-Vuk avatar Jul 06 '17 22:07 Igor-Vuk