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

Issues parsing React Fragment short syntax #43

Closed
swissspidy opened this issue Aug 20, 2021 · 1 comment
Closed

Issues parsing React Fragment short syntax #43

swissspidy opened this issue Aug 20, 2021 · 1 comment

Comments

@swissspidy
Copy link

Originally reported at wp-cli/i18n-command#280, Peast fails to parse the following JSX using the <>/</> shorthand syntax for React fragments:

import React from 'react';

export default class Example extends React.Component {
  render() {
    return (
        <div className="example">
          <>
          </>
        </div>
    );
  }
}

Errror:

Peast\Syntax\Exception: Unexpected: >

Fragments are being parsed fine if they're on the outmost side though:

export default class Example extends React.Component {
  render() {
    return (
      <>
        <div className="example">
        </div>
      </>
    );
  }
}
@mck89
Copy link
Owner

mck89 commented Aug 23, 2021

I'm not a React expert so i had to find some documentation when writing the JSX parser and that documentation didn't allow fragments inside elements. I tried that syntax and it works with React so i've implemented it, now it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants