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
{{ message }}
Repository navigation
When css modules are in the scss file, refer to the css file, where the variable value of the css file is exported as undefined #382
importReactfrom"react";importReactDomfrom"react-dom";import{love,yong1}from'./scss/style/index.scss';console.log(yong1);// is undefined functionApp(){return(<divclassName={`${love}${yong1}`}data-theme="light"><divdata-before="$">1w</div></div>);}ReactDom.render(<App/>,document.getElementById("root"));exportdefaultApp
Because CSS modules are transpiled to a module with one default export that contains an object with key values, not a module with multiple named exports.
Because CSS modules are transpiled to a module with one default export that contains an object with key values, not a module with multiple named exports.
I tried your method and found that styles are undefined, I configured namedExport: true of css modules on webpack, so it will be named export by default . so troubled
Activity
IgorSzymanski commentedon Oct 18, 2022
Because CSS modules are transpiled to a module with one default export that contains an object with key values, not a module with multiple named exports.
The same reason you cannot do this:
Instead you have to grab the default export and pick values from the imported object.
Which in your case translates to:
dongjinc commentedon Oct 21, 2022
I tried your method and found that styles are undefined, I configured namedExport: true of css modules on webpack, so it will be named export by default . so troubled