'Is there anyway in styled-components to extend createGlobalStyle
I am importing GlobalStyle from a library which has been created using createGlobalStyle.
Is there any way to extend like ...
cont { GlobalStyle } from "another-library";
const exetendGlobal = styled(GlobalStyle)`
select {
background-color: #f60;
}`
Solution 1:[1]
I believe createGlobalStyle as a method is NOT extendable.
However, you could abstract the css from the other global style and include to get the desired effect...
SomeGlobalCss.js
import { css } from "styled-components"
Const SomeGlobalCss = css`
body {
background: red;
}
`
export { SomeGlobalCss }
Then import and include in global file:
App.js
import { SomeGlobalCss } from "another-library"
const GlobalStyle = createGlobalStyle`
${ SomeGlobalCss }
body {
background: green;
}
`
export { GlobalStyle }
Here, you can then include SomeGlobalCss.js, wherever you wish...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | davidford.me |