sandpack icon indicating copy to clipboard operation
sandpack copied to clipboard

get no a sandboxId

Open Royal18625194910 opened this issue 6 months ago • 0 comments

Bug report

Packages affected

  • [x] sandpack-client
  • [ ] sandpack-react

Description of the problem

get no a sandboxId???

import {
	SandpackPreview,
	SandpackPreviewRef,
	useSandpack,
} from "@codesandbox/sandpack-react";
import { useEffect, useRef } from "react";

interface SandPackPreviewClientProps {
	isPreview: boolean;
}

const SandPackPreviewClient = ({ isPreview }: SandPackPreviewClientProps) => {
	const previewRef = useRef<SandpackPreviewRef>(null);
	const { sandpack } = useSandpack();

	useEffect(() => {
		console.log("previewRef.current", previewRef.current);
		const client = previewRef.current?.getClient();
		if (client) {
			const clientId = previewRef.current?.clientId;
			console.log("client", client, clientId);
			console.log("sandpack", sandpack.clients, sandpack);
		}
	}, [sandpack]);
	return (
		<SandpackPreview
			ref={previewRef}
			style={{ height: "88vh" }}
			showNavigator
		/>
	);
};

export default SandPackPreviewClient;

Royal18625194910 avatar Apr 08 '25 03:04 Royal18625194910