Skip to content
This repository was archived by the owner on May 19, 2018. It is now read-only.
/ babylon Public archive
This repository was archived by the owner on May 19, 2018. It is now read-only.

How can I parse JSX with attributes? #4

@kuu

Description

@kuu

Sorry for using this issue for asking questions.
But I don't understand how to parse JSX with attributes.

I wanted to write a babel plugin to transform JSX code.
I can get an AST with the following code:

var babylon = require('babylon');
var code = '\
    <Outer>\
      <Inter />\
    </Outer>\
';
var ast = babylon.parse(code, {
  sourceType: 'module',
  plugins: ['jsx']
});

However, an error occurs with the following code:

var code = '\
    <Outer>\
      <Inter value=0 />\
    </Outer>\
';

The error is:

SyntaxError: JSX value should be either an expression or a quoted JSX text

Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions