Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gatsby-plugin-mdx throws on empty line in JSX block #17947

Closed
rakannimer opened this issue Sep 27, 2019 · 5 comments
Closed

gatsby-plugin-mdx throws on empty line in JSX block #17947

rakannimer opened this issue Sep 27, 2019 · 5 comments
Assignees
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@rakannimer
Copy link

rakannimer commented Sep 27, 2019

Description

When I add a an empty line in a function in a JSX block of an MDX file gatsby-plugin-mdx/loaders/mdx-loader.js throws :

SyntaxError: unknown: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...</>?

Steps to reproduce

You can either clone this repo : https://github.com/rakannimer/gastby-plugin-mdx-issue-repro

or

gatsby new mdx-gatsby https://github.com/ChristopherBiscardi/gatsby-starter-mdx-basic
cd mdx-gatsby
  1. In src/pages/index.mdx add :
import { useState } from "react";

<div>
  <h2>count </h2>
  {() => {
    const [count, setCount] = useState(0);

    return <div onClick={() => setCount(count + 1)}>Some message {count}</div>;

}}

</div>
  1. npm start

Expected result

It should allow for empty lines in jsx code blocks.

Actual result

It threw an error.

Environment

System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.16.0 - /var/folders/jn/3z685bls0mv64x4q1vjrzgy40000gn/T/yarn--1569592481666-0.7159453631127595/node
Yarn: 1.17.3 - /var/folders/jn/3z685bls0mv64x4q1vjrzgy40000gn/T/yarn--1569592481666-0.7159453631127595/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 77.0.3865.90
Firefox: 67.0.4
Safari: 12.1.1
npmPackages:
gatsby: ^2.13.50 => 2.13.50
gatsby-image: ^2.2.8 => 2.2.8
gatsby-plugin-manifest: ^2.2.4 => 2.2.4
gatsby-plugin-mdx: ^1.0.46 => 1.0.46
gatsby-plugin-offline: ^2.2.4 => 2.2.4
gatsby-plugin-react-helmet: ^3.1.3 => 3.1.3
gatsby-plugin-sharp: ^2.2.9 => 2.2.9
gatsby-source-filesystem: ^2.1.8 => 2.1.8
gatsby-transformer-sharp: ^2.2.5 => 2.2.5

@johno johno added topic: MDX type: bug An issue or pull request relating to a bug in Gatsby labels Sep 27, 2019
@johno johno self-assigned this Sep 27, 2019
@kgabryje
Copy link

kgabryje commented Oct 6, 2019

Hey, can I take this one?

@samjt
Copy link

samjt commented Oct 9, 2019

This is actually an issue with mdx-js
mdx-js/mdx#767

@csywweb
Copy link

csywweb commented Oct 10, 2019

i have a same question

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 31, 2019
@gatsbot gatsbot bot closed this as completed Nov 11, 2019
@samjt
Copy link

samjt commented Nov 12, 2019

This issue isn’t resolved, the problem still exists up the dependency tree

@gatsbyjs gatsbyjs deleted a comment from gatsbot bot Nov 12, 2019
@gatsbyjs gatsbyjs deleted a comment from gatsbot bot Nov 12, 2019
@johno johno reopened this Nov 12, 2019
@johno johno added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Nov 12, 2019
@johno
Copy link
Contributor

johno commented Dec 16, 2019

I'm going to go ahead and close this since it needs to be addressed upstream. There's nothing actionable on Gatsby or gatsby-plugin-mdx's end.

@johno johno closed this as completed Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants