Skip to content

Local variables derived from props #2290

Discussion options

You must be logged in to vote

Heya @glitteringkatie 👋

Is this expected behavior?

It is.

illustrative example

exports in MDX are available outside the component.
An example which illustrates this:

export const isClassic = true;

## All about {props.feature}

Paragraph

{isClassic ? 'More about this concept' : 'Whatever'}

is compiled to

/*@jsxRuntime automatic @jsxImportSource react*/
const {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0];
const isClassic = true;
function _createMdxContent(props) {
  const _components = Object.assign({
    h2: "h2",
    p: "p"
  }, props.components);
  return _jsxs(_Fragment, {
    children: [_jsxs(_components.h2, {
      children: ["All about ", props.feature]
    }), "\n",

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@glitteringkatie
Comment options

Answer selected by glitteringkatie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants