1

I'm looking for a way but I can't find how do I add a preset or plugin for babel to transpile the bind operator.

Can I do this (and how), or you can't modify configuration on create-react-app?

Christopher Francisco
  • 15,672
  • 28
  • 94
  • 206

1 Answers1

1

There is a transform-function-bind Babel plugin. However, create-react-app does not let you modify the underlying Babel configuration, so you would have to npm run eject (which is generally not recommended because you'd be losing the ability to update react-scripts). I would recommend ignoring this feature if you don't need it, and you may want to consider not using create-react-app (or ejecting) if you find it necessary.

Nick McCurdy
  • 17,658
  • 5
  • 50
  • 82
  • Bummer. What is your preferred way to do it? – Mark Karavan Aug 23 '17 at 02:53
  • I use arrow functions with property initializers for React handlers. These are both supported in `create-react-app`. https://babeljs.io/docs/plugins/transform-es2015-arrow-functions/ https://babeljs.io/docs/plugins/transform-class-properties/ – Nick McCurdy Aug 23 '17 at 12:03