Socket
Socket
Sign inDemoInstall

@mdx-js/react

Package Overview
Dependencies
5
Maintainers
4
Versions
117
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.3.0

17

lib/index.d.ts

@@ -11,3 +11,3 @@ /**

export function withMDXComponents(Component: import('react').ComponentType<any>): (props: Record<string, unknown> & {
components?: Components;
components?: Components | null | undefined;
}) => JSX.Element;

@@ -17,3 +17,3 @@ /**

*
* @param {Components|MergeComponents} [components]
* @param {Components | MergeComponents | null | undefined} [components]
* Additional components to use or a function that takes the current

@@ -24,3 +24,3 @@ * components and filters/merges/changes them.

*/
export function useMDXComponents(components?: import("mdx/types").MDXComponents | MergeComponents | undefined): Components;
export function useMDXComponents(components?: Components | MergeComponents | null | undefined): Components;
/**

@@ -45,3 +45,3 @@ * Provider for MDX context

export type ReactNode = import('react').ReactNode;
export type Components = import('mdx/types').MDXComponents;
export type Components = import('mdx/types.js').MDXComponents;
/**

@@ -54,12 +54,15 @@ * Configuration.

*/
components?: import("mdx/types").MDXComponents | undefined;
components?: Components | MergeComponents | null | undefined;
/**
* Turn off outer component context.
*/
disableParentContext?: boolean | undefined;
disableParentContext?: boolean | null | undefined;
/**
* Children.
*/
children?: ReactNode;
children?: ReactNode | null | undefined;
};
/**
* Custom merge function.
*/
export type MergeComponents = (currentComponents: Components) => Components;
/**
* @typedef {import('react').ReactNode} ReactNode
* @typedef {import('mdx/types').MDXComponents} Components
* @typedef {import('mdx/types.js').MDXComponents} Components
*
* @typedef Props
* Configuration.
* @property {Components} [components]
* @property {Components | MergeComponents | null | undefined} [components]
* Mapping of names for JSX components to React components.
* @property {boolean} [disableParentContext=false]
* @property {boolean | null | undefined} [disableParentContext=false]
* Turn off outer component context.
* @property {ReactNode} [children]
* @property {ReactNode | null | undefined} [children]
* Children.
*
* @callback MergeComponents
* Custom merge function.
* @param {Components} currentComponents

@@ -48,3 +49,3 @@ * Current components from the context.

/**
* @param {Record<string, unknown> & {components?: Components}} props
* @param {Record<string, unknown> & {components?: Components | null | undefined}} props
* @returns {JSX.Element}

@@ -61,3 +62,3 @@ */

*
* @param {Components|MergeComponents} [components]
* @param {Components | MergeComponents | null | undefined} [components]
* Additional components to use or a function that takes the current

@@ -70,2 +71,3 @@ * components and filters/merges/changes them.

const contextComponents = React.useContext(MDXContext)
// Memoize to avoid unnecessary top-level context changes

@@ -92,6 +94,12 @@ return React.useMemo(() => {

export function MDXProvider({components, children, disableParentContext}) {
let allComponents = useMDXComponents(components)
/** @type {Components} */
let allComponents
if (disableParentContext) {
allComponents = components || emptyObject
allComponents =
typeof components === 'function'
? components({})
: components || emptyObject
} else {
allComponents = useMDXComponents(components)
}

@@ -98,0 +106,0 @@

{
"name": "@mdx-js/react",
"version": "2.2.1",
"version": "2.3.0",
"description": "React context for MDX",

@@ -59,3 +59,3 @@ "license": "MIT",

"prepack": "npm run build",
"build": "rimraf \"lib/**/*.d.ts\" \"test/**/*.d.ts\" \"index.d.ts\" && tsc && type-coverage",
"build": "tsc --build --clean && tsc --build && type-coverage",
"test-api": "node --no-warnings --experimental-loader=../../script/jsx-loader.js ../../node_modules/uvu/bin.js test \"\\.jsx?$\"",

@@ -62,0 +62,0 @@ "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc