Skip to content

Commit

Permalink
Use mdxType as prop name (#462)
Browse files Browse the repository at this point in the history
In some cases it might be desired to access
the type prop. This namespaces it with mdx
to become mdxType. This shouldn't clash with
most components and allows wrapper to more
easily inspect its children's type like you
would with most React elements.
  • Loading branch information
johno authored Mar 12, 2019
1 parent 2751ced commit 490f700
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/mdx/create-element.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const React = require('react')
const {useMDXComponents} = require('@mdx-js/tag')

const TYPE_PROP_NAME = '__MDX_TYPE_PLEASE_DO_NOT_USE__'
const TYPE_PROP_NAME = 'mdxType'

const DEFAULTS = {
inlineCode: 'code',
Expand All @@ -10,12 +10,12 @@ const DEFAULTS = {

const MDXCreateElement = ({
components: propComponents,
__MDX_TYPE_PLEASE_DO_NOT_USE__,
mdxType,
parentName,
...etc
}) => {
const components = useMDXComponents(propComponents)
const type = __MDX_TYPE_PLEASE_DO_NOT_USE__
const type = mdxType
const Component =
components[`${parentName}.${type}`] ||
components[type] ||
Expand Down

0 comments on commit 490f700

Please sign in to comment.