-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
CSS generation not working with Emotion cache enabled #3071
Comments
UPDATE: Apparently there is a problem during Here is the code:
import { FunctionComponent, useEffect, useState } from 'react';
import { CacheProvider, EmotionCache } from '@emotion/react';
interface Props {
cache: EmotionCache;
}
const CustomEmotionCacheProvider: FunctionComponent<Props> = ({ cache, children }) => {
const [ isFirstRender, setIsFirstRender ] = useState(true);
useEffect(() => setIsFirstRender(false), []);
return (
<CacheProvider value={cache}>
{!isFirstRender && children}
</CacheProvider>
);
};
export default CustomEmotionCacheProvider;
const shadowrootCache = createCache({
key: 'shadowroot-cache',
container: domElement,
prepend: true
});
const Root = () => (
<CustomEmotionCacheProvider cache={shadowrootCache}>
<Select
options={[
{ label: 'Test', value: 'test' },
{ label: 'Test 2', value: 'test-2' },
{ label: 'Test 3', value: 'test-3' }
]}
/>
</CustomEmotionCacheProvider>
);
ReactDOM.render(<Root/>, domElement); Broken CodeSandbox example using shadow DOM: here |
@goldmont do you know how this could work for IFrame. using e.g //App.js
import CreatableSelect from 'react-select/creatable';
function App() => {
return <CreatableSelect
options={options}
value={mainTopic}
onChange={(newValue) =>{}}
/>
} //content.js
import React from 'react';
import ReactDOM from 'react-dom';
import Frame, { FrameContextConsumer } from 'react-frame-component';
import App from "./App";
function Main() {
return (
<Frame head={[<link type="text/css" rel="stylesheet" href={chrome.runtime.getURL("/static/css/content.css")} ></link>]}>
<FrameContextConsumer>
{
({ document, window }) => {
return <App document={document} window={window} isExt={true} />
}
}
</FrameContextConsumer>
</Frame>
)
} |
react-select css forsvinner når man bruker shadowDom element. Dette fikser det. se f. eks JedWatson/react-select#3680 og emotion-js/emotion#3071 (comment) for mer info
react-select css forsvinner når man bruker shadowDom element. Dette fikser det. se f. eks JedWatson/react-select#3680 og emotion-js/emotion#3071 (comment) for mer info
This was marked as completed but where is the relevant PR in the emotion-js repo? I ask because running into something very similar with: chakra-ui/chakra-ui#8241 |
Issue description
I'm using react-select library in a shadow DOM.
In my tests I used the following code (no customizations):
By the way, the layout is totally broken because apparently
Emotion
is unable to output the CSS. The class names are set in theclass
attributes but the classes themselves don't exist.Here is a CodeSandbox reproducing the issue.
Here is another CodeSandbox not using shadow DOM and thus working as expected.
Hoping in a prompt reply. Thanks.
The text was updated successfully, but these errors were encountered: