Giter Club home page Giter Club logo

bug-reproduce-1's People

Watchers

 avatar

bug-reproduce-1's Issues

Bug: metro-babel7-plugin-react-transform transforms some class properties incorrectly

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
Class properties, defined as ClassName.propertyName = .... are undefined

class User extends React.Component {
  render() {
    console.log(User.propTypes) // undefined
    console.log(User.myStaticProperty) // undefined
  }
}
User.propTypes = {};
User.myStaticProperty = '42';

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

class User extends React.Component {
  render() {
    console.log(User.propTypes) // {}
    console.log(User.myStaticProperty) // '42'
  }
}
User.propTypes = {};
User.myStaticProperty = '42';

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

// package.json:
    "@babel/cli": "^7.2.3",
    "@babel/core": "^7.3.4",
    "@babel/plugin-proposal-class-properties": "^7.3.4",
    "@babel/preset-env": "^7.3.4",
    "@babel/preset-react": "^7.0.0",
    "metro-babel7-plugin-react-transform": "^0.52.0",
// babel.config.js
module.exports = {
  presets: ['@babel/env', '@babel/react'],
  plugins: ['@babel/proposal-class-properties'],
  env: {
    development: {
      plugins: [
        [
          'module:metro-babel7-plugin-react-transform',
          {
            transforms: [{
              transform: 'react-transform-hmr',
              imports: ['react'],
              locals: ['module'],
            }],
          },
        ],
      ],
    },
  },
};

node: 10.15.1
yarn: 1.13.0

It looks like some changes were made in this method: https://github.com/facebook/metro/blob/08f41b7d3d937738492d17f4a92e135d4c1134fa/packages/metro-babel7-plugin-react-transform/src/index.js#L151
We believe, that might be a cause of this bug.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.