Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@mdx-js/runtime
Advanced tools
@mdx-js/runtime
A React component that evaluates MDX.
:warning: warning: this is not the preferred way to use MDX since it introduces a substantial amount of overhead and dramatically increases bundle sizes. It must not be used with user input that isn’t sandboxed.
npm:
npm install @mdx-js/runtime
yarn:
yarn add @mdx-js/runtime
Say we have the following scripts, example.jsx
:
The MDX Runtime component accepts two props:
Name | Description |
---|---|
components | Globally available components for the runtime |
scope | Variables that are accessible in the JSX portion of the document |
remarkPlugins | Array of remark plugins |
import React from 'react'
import {renderToString} from 'react-dom/server'
import MDX from '@mdx-js/runtime'
// Custom components:
const components = {
h1: props => <h1 style={{color: 'tomato'}} {...props} />,
Demo: () => <p>This is a demo component</p>
}
// Data available in MDX:
const scope = {
somethingInScope: 1
}
// The MDX:
const children = `
# Hello, world!
{1 + somethingInScope}
<Demo />
<div>Here is the scope variable: {some}</div>
`
const result = renderToString(
<MDX components={components} scope={scope} children={children} />
)
console.log(result)
Now, building, bundling, and finally running it, yields:
<h1 style="color:tomato">Hello, world!</h1>
2
<p>This is a demo component</p>
See Contributing on mdxjs.com
for ways to get started.
See Support for ways to get help.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
MIT © Compositor and Vercel
FAQs
Deprecated: this package is no longer maintained.
The npm package @mdx-js/runtime receives a total of 0 weekly downloads. As such, @mdx-js/runtime popularity was classified as not popular.
We found that @mdx-js/runtime demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.