Skip to content
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

Add Sandpack support to embed DevTools into Beta docs #4159

Closed
wants to merge 1 commit into from

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Dec 9, 2021

Builds on top of the work done by @danilowoz in codesandbox/sandpack#236

  • Update Code Sandbox Sandpack to 0.10.1
    • The SandpackCodeEditor currently throws an error ("Unrecognized extension value in extension set ([object Object])...")
  • Update Sandpack plug-in to support conditionally rendering SandpackReactDevTools
  • Work with @danilowoz to style embedded DevTools

@bvaughn
Copy link
Contributor Author

bvaughn commented Dec 9, 2021

Looking at the docs and this template I was able to figure out how to get the latest release prtially working in create-react-app:

import {
  SandpackCodeEditor,
  SandpackLayout,
  SandpackPreview,
  SandpackProvider,
  SandpackReactDevTools,
} from "@codesandbox/sandpack-react";

import "@codesandbox/sandpack-react/dist/index.css";

const INDEX_HTML = `
  <html>
    <body>
      <script src="/App.js"></script>
    </body>
  <html>
`;

const APP_JS = `
  export default function App() {
    return (
      <div>Hello world</div>
    );
  }
`;

const CONFIG = {
  entry: "/public/index.html",
  main: "/App.js",
  files: {
    "/public/index.html": INDEX_HTML,
    "/App.js": APP_JS,
  }
};

export default function App() {
  return (
    <SandpackProvider template="react" customSetup={CONFIG}>
      <SandpackLayout>
        <SandpackCodeEditor />
        <SandpackPreview />
        <SandpackReactDevTools />
      </SandpackLayout>
    </SandpackProvider>
  );
}

Note that although the Sandpack renders without visible errors, DevTools doesn't seem to successfully connect to the demo app:
Screen Shot 2021-12-09 at 3 57 01 PM

cc @danilowoz in case this is unexpected

@harish-sethuraman
Copy link
Collaborator

I'll close this since we have already merged the devtools PR to main :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants