AlexGilleran / jsx-control-statements

Neater If and For for React JSX
https://www.npmjs.com/package/babel-plugin-jsx-control-statements
MIT License
1.62k stars 64 forks source link

Uncaught ReferenceError: Choose is not defined #78

Closed MuYunyun closed 6 years ago

MuYunyun commented 6 years ago

I do as the step readme show. Howerver, the browser still error with Uncaught ReferenceError: Choose is not defined. This babel-plugin don't do effort in my app.

my jsx as follow:

<Choose>
  <When condition={true}>
    111
  </When>
  <Otherwise>
    222
  </Otherwise>
</Choose>

This is my .babelrc

// .babelrc
{
  "presets": ["es2015", "react"],
  "plugins": [
    "jsx-control-statements",
    "transform-async-to-generator",
    "transform-class-properties",
    "transform-decorators-legacy",
    "transform-object-rest-spread"
  ]
}
"babel-core": "^6.23.1",
"babel-loader": "^6.2.10",

I use webpack to run my app, and the print as follow: image

AlexGilleran commented 6 years ago

:man_shrugging: works for me. Did you npm install --save-dev babel-plugin-jsx-control-statements or npm install --save-dev jsx-control-statements ?

MuYunyun commented 6 years ago

I do yarn add babel-plugin-jsx-control-statements.I doubt if the plugin's incompatible in the low version babel(6.x) or be covered by other plugin(not only babel-plugin-syntax-jsx)?

MuYunyun commented 6 years ago

emm, I‘ve found the reason. The Project actually has two .babelrc, and I change the error one. 😭

AlexGilleran commented 6 years ago

:joy: :+1: