remcohaszing/babel-plugin-transform-react-class-to-function

Cannot use import * as React from 'react';

Closed this issue · 2 comments

Type: bug|docs|feature
OP can fix: ✘
Plugin version: 1.1.2
Babel version: 7.1.2
Contents of .babelrc(.js):

{
presets: ['@babel/preset-react', '@babel/preset-env'],
plugins: [
'babel-plugin-transform-react-class-to-function'
'@babel/plugin-proposal-object-rest-spread',
            '@babel/plugin-proposal-class-properties',
        ]
}

Input code:

import * as React from 'react';

export default class App extends React.Component {
    render() {
        return (
            <div>{this.props.name}</div>
        );
    }
}

Expected output:
Component as function

Actual output:
Component as class

Hi,

I would like to use this plugin but I have a problem with detecting "what is react component". When I use "import React from 'react';" class is converted to function. But I need to import "import * as React from 'react';" because of Typescript hints.

Thank you for your work.

Thank you for your bug report. I’ll probably fix it this weekend. :)

Fixed it. 😄