Open KSXGitHub opened 8 years ago
Is this available right now? Symbols-view doesn't recognise class methods declared using arrow function syntax
class Animal {
constructor(){}
walk = () => {
console.log('walking around')
}
eat(){
console.log('eating grass')
}
}
When I click cmd + r, symbols-view only detect constructor()
and eat()
, walk()
is not detected.
@arrowfunxtion A member variable inside a class? I don't think ES6 has this kind of thing (at least, not yet).
And BTW, your name @arrowfunxtion fit in this proposal perfectly, I wonder if you named it on purpose.
I couldn't say for sure where arrow functions fit into the ES6/7 official plans. But Babel support for them is a default for projects like create-react-app. It would be awesome to be able to use my fuzzy symbol finder again while in React like I can for my Rails code.
class Foo {
bar = () => {
...
}
}
Isn't valid JS as of writing, but the following is:
class Foo {
get bar () {
return () => {
...
}
}
}
@fl0w it isn't valid in vanilla es6, but it is valid babeljs
@KSXGitHub Yea, that's what I ment.
@fl0w I don't see any problem with supporting extra features (babeljs, reactjs, etc.)
I couldn't say for sure where arrow functions fit into the ES6/7 official plans
@KSXGitHub I'm not injecting an opinion here, I was just adding clarification to the comment.
hello @KSXGitHub
class Animal {
constructor(){}
walk = () => {
console.log('walking around')
}
eat(){
console.log('eating grass')
}
}
the walk = () => { ... }
will auto bind this
, and it's show in React's documentation,
and used a lot in React community.
see https://facebook.github.io/react/docs/handling-events.html
@magicdawn Why are you telling me this?
the
walk = () => { ... }
will auto bindthis
How is this even relevant?
I'm just saying it helps React developer a lot on handling events. and used a lot. But this package does not support these class members ...................
@magicdawn Well, then you just need to say that React devs use it a lot. Irrelevant details might be confusing :smile:
Oh, I forgot about my second comment. I was not against member arrow function or anything, that was a bit surprise from me (because es6 doesn't have it)
Arrow functions (named
f
,g
,h
):Classes: