Socket
Socket
Sign inDemoInstall

@mdx-js/react

Package Overview
Dependencies
Maintainers
4
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mdx-js/react - npm Package Compare versions

Comparing version 2.0.0-rc.2 to 2.0.0

19

lib/index.js

@@ -68,11 +68,16 @@ /**

const contextComponents = React.useContext(MDXContext)
// Memoize to avoid unnecessary top-level context changes
return React.useMemo(() => {
// Custom merge via a function prop
if (typeof components === 'function') {
return components(contextComponents)
}
// Custom merge via a function prop
if (typeof components === 'function') {
return components(contextComponents)
}
return {...contextComponents, ...components}
return {...contextComponents, ...components}
}, [contextComponents, components])
}
/** @type {Components} */
const emptyObject = {}
/**

@@ -88,3 +93,3 @@ * Provider for MDX context

if (disableParentContext) {
allComponents = components || {}
allComponents = components || emptyObject
}

@@ -91,0 +96,0 @@

{
"name": "@mdx-js/react",
"version": "2.0.0-rc.2",
"version": "2.0.0",
"description": "React context for MDX",

@@ -51,7 +51,7 @@ "license": "MIT",

"devDependencies": {
"@mdx-js/mdx": "^2.0.0-rc.2",
"@mdx-js/mdx": "^2.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^18.0.0-alpha-327d5c484-20211106",
"react-dom": "^18.0.0-alpha-327d5c484-20211106"
"react": "^18.0.0-beta-24dd07bd2-20211208",
"react-dom": "^18.0.0-beta-24dd07bd2-20211208"
},

@@ -62,3 +62,3 @@ "scripts": {

"test-api": "node --no-warnings --experimental-loader=../../script/jsx-loader.js ../../node_modules/uvu/bin.js test \"\\.jsx?$\"",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run test-coverage"

@@ -65,0 +65,0 @@ },

@@ -39,7 +39,4 @@ # `@mdx-js/react`

This package is not needed for MDX to work with React.
But it is nice if you enjoy context-based props passing to avoid repetition.
This package adds support for a React context based interface to set components
(sometimes known as *shortcodes*) by passing them to an `MDXProvider`, which
then are used in all nested MDX files implicitly.
The alternative is to pass those components to each MDX file.
See [¶ MDX provider in § Using MDX][use-provider] for when and how to use an MDX
provider.

@@ -54,3 +51,3 @@ ## Install

```sh
npm install @mdx-js/react@next
npm install @mdx-js/react
```

@@ -61,3 +58,3 @@

```sh
yarn add @mdx-js/react@next
yarn add @mdx-js/react
```

@@ -69,3 +66,7 @@

import {MDXProvider} from '@mdx-js/react'
import Post from './post.mdx' // Assumes an integration is used to compile MDX -> JS.
import Post from './post.mdx'
// ^-- Assumes an integration is used to compile MDX to JS, such as
// `@mdx-js/esbuild`, `@mdx-js/loader`, `@mdx-js/node-loader`, or
// `@mdx-js/rollup`, and that it is configured with
// `options.providerImportSource: '@mdx-js/react'`.

@@ -218,3 +219,3 @@ const components = {

[coc]: https://github.com/mdx-js/.github/blob/HEAD/code-of-conduct.md
[coc]: https://github.com/mdx-js/.github/blob/main/code-of-conduct.md

@@ -229,3 +230,3 @@ [mit]: https://github.com/mdx-js/mdx/blob/main/packages/react/license

[use-provider]: https://mdxjs.com/using-mdx/#mdx-provider
[use-provider]: https://mdxjs.com/docs/using-mdx/#mdx-provider

@@ -232,0 +233,0 @@ [security]: https://mdxjs.com/getting-started/#security

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc