Skip to content
This repository was archived by the owner on Oct 2, 2021. It is now read-only.

babel-plugin-import + React = forgotten variable alias #15

Open
dandevs opened this issue Apr 23, 2017 · 0 comments
Open

babel-plugin-import + React = forgotten variable alias #15

dandevs opened this issue Apr 23, 2017 · 0 comments

Comments

@dandevs
Copy link

dandevs commented Apr 23, 2017

When babel parses React elements, it forgets the variables alias

import React from "react";
import ReactDOM from "react-dom";
import { Meteor } from "meteor/meteor";

import { LocaleProvider } from "antd";
import enUS from "antd/lib/locale-provider/en_US";

console.log(LocaleProvider);

Meteor.startup(() => {
    ReactDOM.render(
        <LocaleProvider locale={enUS}>
            <h1>Hello World</h1>
        </LocaleProvider>,
        document.getElementById("render-target")
    );
});

Compiles into:

//  ...............

module.importSync("antd/lib/locale-provider/style/css", {
    style: function (v) {
        _style = v;
    }
}, 0);

var _default = void 0;

module.importSync("antd/lib/locale-provider", {
    "default": function (v) {
        _default = v;
    }
}, 1);

//  ...............

console.log(_default); //LocaleProvider=_default.... Right!
Meteor.startup(function () {
    ReactDOM.render(React.createElement(
        LocaleProvider, // <- babel forgot its supposed to be _default
        {
            locale: enUS
        },
        React.createElement(
            "h1",
            null,
            "Hello World"
        )
    ), document.getElementById("render-target"));
});
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant