MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/7ytegt/optional_chaining_may_be_coming_to_javascript/dul41zg/?context=3
r/javascript • u/gregbaugues • Feb 20 '18
100 comments sorted by
View all comments
1
Really want this my code is littered with these. I also want a way to bind methods of JS classes with their own this. I have so many of these in my constructors: this.myfunc = this.myfunc.bind(this)
1 u/SahinK Feb 20 '18 You probably shouldn't call a class member function from a different context anyway. Why do you need this?For callbacks you can usefunctionThatTakesCallback(() => this.method());instead offunctionThatTakesCallback(this.method); 1 u/Extracted Feb 21 '18 Sending functions to child components in React and avoiding creating a new function on every render
You probably shouldn't call a class member function from a different context anyway. Why do you need this?
For callbacks you can use
functionThatTakesCallback(() => this.method());
instead of
functionThatTakesCallback(this.method);
1 u/Extracted Feb 21 '18 Sending functions to child components in React and avoiding creating a new function on every render
Sending functions to child components in React and avoiding creating a new function on every render
1
u/CCB0x45 Feb 20 '18
Really want this my code is littered with these. I also want a way to bind methods of JS classes with their own this. I have so many of these in my constructors: this.myfunc = this.myfunc.bind(this)