ChristopherBiscardi / gatsby-mdx

Gatsby+MDX • Transformers, CMS UI Extensions, and Ecosystem Components for ambitious projects

Home Page:https://gatsby-mdx.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Two identical workspace setups, {children} received from the same mdx files is different?

kuworking opened this issue · comments

I have a gatsby-themes structure where the core theme is importing mdx files that exist in the child theme (child of a child theme actually).

In the core theme I have in gatsby-config

      resolve: `gatsby-mdx`,
      options: {
        defaultLayouts: { default: path.resolve(__dirname, './src/templates/template-mdx.js') },
      },

And in template-mdx.js I have

export const TemplateMdx = ({ children, location, pageContext }) => {
...
  console.log(children)
  console.log(location)
  console.log(pageContext)
...
}

With this workspace structure, {children} is

Capture01

Which I then use to display the content.
*Not relevant here, but I use this strategy so that I can inspectionate the content looking for a dataset element where I can then paste some content not originally present in the mdx file

Then, the thing is that I have cloned the workspace (manually creating the folders and copying files), I've changed the names where it was necessary, and then run the site as usual (yarn workspace...) after installing the packages. Importantly, the package.json files point to specific versions with all packages with the ^ operator, such as:

    "@mdx-js/mdx": "^0.20.3",
    "@mdx-js/tag": "^0.20.3",
    "gatsby-mdx": "^0.4.2",

So that the two workspaces are (or should be) identical in this sense

The problem is that when now I try to reach any mdx files, the {children} is different in the new workspace, as shown here:

Capture02

As you can see, the previous {children} array is now under props.children.

If that was a consequence of a new version of the plugin, I'd update the code and that's it, but here at least in theory I do have the exact same versions of everything, so why am I getting these different behaviors?

Any idea of why is this happening? I have been looking for any difference between the two workspaces, but I can't find any. Does it ring any bell to you?

Nothng, the core theme had a different version of gatsby-mdx, and for some reason in one workspace it had installed the child one, and in the second workspace the core one. Since I can't delete it I close it :)