styleguidist / react-styleguidist

Isolated React component development environment with a living style guide
https://react-styleguidist.js.org/
MIT License
10.84k stars 1.44k forks source link

Try rendering examples in iframe #1496

Open sapegin opened 4 years ago

sapegin commented 4 years ago

Right now each example is a separate React app that renders into the same DOM as the Styleguidist app itself. This approach have some problems:

Possible issues of the iframe approach:

stepancar commented 4 years ago

@sapegin , we used https://www.npmjs.com/package/react-frame-component about 1.5 year ago, it was not bad.

psjsaravana commented 4 years ago

This could help for sharing the styles between iframe

import Frame from "react-frame-component";

const initialContent = `<!DOCTYPE html><html><head>${document.head.innerHTML}</head><body><div></div></body></html>`;

<Frame style={{ width: "80%", margin: "auto 10%" }} initialContent={initialContent}>
    <YourComponent title="Title" />
</Frame>;
sapegin commented 4 years ago

The main goal of using iframes is to prevent sharing anything between the host and iframes.

sapegin commented 4 years ago

There's a pull request with draft implementation: #1553.