LoginSignup
4
1

More than 5 years have passed since last update.

react-decoration で @ がだめだと言われたときに通す方法は transform-decorators-legacy を使う

Last updated at Posted at 2017-05-31

@ が通らなくなった問題発生

React の react-decoration を使っていたところ、バージョンアップしたら

ERROR in ./hoge.js
Module build failed: SyntaxError: Unexpected token (16:2)

  14 |   }
  15 | 
> 16 |   @debounce(375)
     |   ^

などと、@ が変だと言われるようになってしまった。

you ばべっちゃっいなよってことで次のように babe ったらなおった

READMEにしたがって (詳細は react-decoration/Introduction.md を参照のこと)、

$ yarn add babel-plugin-transform-decorators-legacy

babel-plugin-transform-decorators-legacy という npm を追加し、さらに .babelrc に、

{
  "plugins": [
    ...,
    "transform-decorators-legacy",
    ...
  ],
  "...": ...
}

と追加したら @ が再び使えるようになった。よかった。

legacy という名前だということは、今は違う方法が推奨されているのかも知れないが、そこまでは勉強していない。

  • react-decoration v1.4.1

babel 6

babel 6 だと起きるということです。Thanks, @eielh.

4
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1