How to use the @mdx-js/react.useMDXComponents function in @mdx-js/react

To help you get started, we’ve selected a few @mdx-js/react examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blocks / blocks / packages / gatsby-theme-blocks-docs / src / components / code-preview.js View on Github external
export default ({
  code,
  scope = defaultScope,
  mdx,
  editable = true,
  className,
  ...props
}) => {
  const theme = useContext(ThemeContext)
  const components = useMDXComponents()

  const fullScope = { ...scope, ...components }
  delete fullScope.delete // TODO: Better handle this

  return (
github gatsbyjs / gatsby / packages / gatsby-plugin-mdx / mdx-renderer.js View on Github external
module.exports = function MDXRenderer({
  scope,
  components,
  children,
  ...props
}) {
  const mdxComponents = useMDXComponents(components);
  const mdxScope = useMDXScope(scope);

  // Memoize the compiled component
  const End = React.useMemo(
    () => {
      if (!children) {
        return null;
      }

      const fullScope = {
        // React is here just in case the user doesn't pass them in
        // in a manual usage of the renderer
        React,
        mdx,
        ...mdxScope
      };
github patternfly / patternfly-react / packages / patternfly-4 / react-docs / src / components / mdx-renderer.js View on Github external
export function MDXRenderer({ scope, components, children, ...props }) {
  const mdxComponents = useMDXComponents(components);
  const mdxScope = useMDXScope(scope);

  if (!children) {
    return null;
  }

  const fullScope = {
    // React is here just in case the user doesn't pass them in
    // in a manual usage of the renderer
    React,
    mdx,
    ...mdxScope
  };

  // children is pre-compiled mdx
  children = children.replace(/_frontmatter: _frontmatter/gm, '');
github modulz / radix / packages / website / src / components / CodeBlock.js View on Github external
export default ({ children, live, removeFragment }) => {
  const components = useMDXComponents();

  const liveProviderProps = {
    transformCode: code => (removeFragment ? code : `<>${code}`),
    scope: { mdx, ...components },
  };

  if (live) {
    return (

@mdx-js/react

React context for MDX

MIT
Latest version published 1 month ago

Package Health Score

97 / 100
Full package analysis