react-live-unplugin
Version:
Turn React components into live code blocks with ease.
23 lines (22 loc) • 514 B
JavaScript
import Playground from "@docusaurus/theme-live-codeblock/lib/theme/Playground";
import React, { useMemo } from "react";
import { transformCode } from "../transformCode.js";
const LiveCodeBlock = ({ scope, ...props }) => {
const mergedScope = useMemo(
() => ({
...React,
...scope
}),
[scope]
);
return /* @__PURE__ */ React.createElement(
Playground,
{
...props,
noInline: true,
scope: mergedScope,
transformCode
}
);
};
export { LiveCodeBlock };