Cannot access directly the style from style object
See original GitHub issueAfter upgrading to 4.0.0
I have some issue with access to style object.
- Previous version: 3.0.1
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'container': string;
'large': string;
'medium': string;
'small': string;
}
declare const cssExports: CssExports;
export = cssExports;
usage console.log(style.container);
- Version: 4.0.0
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'container': string;
'large': string;
'medium': string;
'small': string;
}
export const cssExports: CssExports;
export default cssExports;
usage console.log(style.default.container);
Now I have to add one more key .default
to access to the style object
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6
Top Results From Across the Web
Why doesn't DOM style object set CSS variables directly?
It's because DOM's Style function only understands HTML properties and not CSS properties. Defining CSS properties are listed in style's ...
Read more >Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >HTMLElement.style - Web APIs | MDN
The style read-only property returns the inline style of an element in the form of a CSSStyleDeclaration object that contains a list of...
Read more >Styling in React: 5 ways to style React apps - LogRocket Blog
So, instead of adding the styles inline directly, as we did in the previous example, we just pass the object variables as you...
Read more >How to Style Your React App – 5 Ways to Write CSS in 2021
Inline styles are the most direct away to style any React application. ... For example, you cannot write animations, styles for nested ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the exact same issue as @tonyelewis
If I do
import * as styles from "./TabHeader.css";
the code works, but TypeScript throws errors.
If I do
import styles from "./TabHeader.css";
TypeScript is happy but the code does not work.
A downgrade from 4.0.0 to 3.0.1 fixes the issue but is obviously not a long term solution.
Anyway, thanks for the loader! 😃
@tonyelewis When I was using it, I found similar problems, It will only be right the first time it works that
import styles from "./xxxx"
,secondimport styles from "./xxxx"
will wrong .That’s how I do it. i find this issues esModule option behaviour
Solve in this file style-loader/src/index.js Line 28
it will work right. But I didn’t find the reason why
delete options.esModule
in the code.