import { CodeSnippet, CodeSnippetProps, renderElementToJSX } from '@fluentui/docs-components'; import * as React from 'react'; type ComponentPlaygroundSnippetProps = { element?: React.ReactElement; component?: React.FunctionComponent; } & Partial; /** * This component uses `react-element-to-jsx-string` to get a generated markup with props. */ const ComponentPlaygroundSnippet: React.FunctionComponent = props => { const { element, component, ...rest } = props; if (process.env.NODE_ENV !== 'production') { if (typeof component === 'function' && !!component.prototype.isReactComponent) { throw new Error('We can handle only functional components as root component.'); } if (!element && !component) { throw new Error('"element" or "component" should be specified'); } } const jsxElement = element || component(null); const jsxMarkup = renderElementToJSX(jsxElement); return ; }; export default ComponentPlaygroundSnippet;