I don’t know enough about the inner workings of things to properly understand why this isn’t working.
I am trying to use the proper class formatting for setting up my components.
Now this means using the constructor to bind this to my functions within that component.
This is a little frustrating to do over and over again…
eg. having to do this for every function where I want to use this…
I think that this means setting up your functions within the class like this:
tick = () => {
...
}
However this throws a weird error which isn’t making sense to me…
Error: Missing class properties transform
Does anyone know how to make this work?
Am I doing something wrong?
I’ve searched online and people seem to point to Babel configs and other things I have no clue about
Thanks for linking me there!
I had a look and the discussion is exactly what I am after - however I think that I am doing everything right code wise.
@warmbowski@ffxsam ITT you guys mention some Babel setup required? I haven’t added Babel or anything… is that why it isn’t working for me? Do I just: meteor npm install babel-plugin-transform-class-properties and add that .babelrc?
Why do I need to do this, the React docs seem to make it sound like it is standard ES6 code…
Maybe I just need to try it again… maybe I missed something because I was tired
I was doing exactly everything that medium article said to do for Best Solution: ES2015 Arrow Functions.
It seems that babel plugins should be supported, as of 1.3.3. You might look at this issue thread for any clues on getting it to work. I don’t know if anything has been updated around babel plugins in 1.4.
I am confused… What are class properties?
I am trying to do exactly what the author of the article @psilotec posted is doing. There is no mentioned of class properties. I am just trying to use the arrow functions to auto-bind? Does that use class properties in the background?
oh I’m understanding more now… found this article: egorsmirnov…
using the arrow notation means I am using class properties. instead of defining functions, I am setting properties within the class to be my functions.
Check out this blog post on babel’s site: https://babeljs.io/blog/2015/06/07/react-on-es6-plus
"Class Properties" seem to encompass the two sections marked Property Initializers and Arrow Functions. Basically things that you would usually include in the constructor.
I am adding this answer to this old discussion in case some are still looking for answers. In order to be able to use class properties you need to:
meteor npm install --save-dev babel-preset-stage-2
and then add a preset to your .babelrc file (add .babelrc file in the root directory of your project) :
{
“presets”: [ “stage-2”]
}