ryanseddon / react-frame-component

Render your React app to an iFrame
http://ryanseddon.github.io/react-frame-component/
MIT License
1.75k stars 156 forks source link

scss style component styles doesn't work in react-frame-component #226

Closed raguct25 closed 2 years ago

raguct25 commented 2 years ago

I have used scss styles in render component whenever i render directly the styles applied properly. but i render inside the react-frame the styles doesn't apply.

import Frame from 'react-frame-component';

<Frame>
  <Placeholder
    name="jss-help-center-l3-white-test"
    rendering={rendering}
    renderEach={RenderTemplateComponent}
    errorComponent={PlaceholderError}
  />
</Frame>

with Frame output:

image

without frame output:

image

what I do for apply scss style.

ryanseddon commented 2 years ago

You need to inject the styles into the iframe, if your using a <link> tag then you can pass that to the head prop:

<Frame head={<link href="/path/to/styles.css" rel="stylesheet">}>
...
</Frame>

Other options are to copy the link tags from the parent document into the frame using contentDidMount.