React: Is using `=>` instead of `bind(this)` still experimental, if so what does it means?

Created on 28 Jul 2017  路  5Comments  路  Source: facebook/react

In this documentation page, using arrow function instead of this.fu.bind(this) is marked as experimental. Is it still considered experimental, if so why?

All 5 comments

What is experimental is not the => part, but the handleClick = part. The non-experimental way of writing it would be to do this.handleClick = inside the constructor.

@Kovensky I see. So why is it experimental? As far as I know it is Stage 3 proposal.

Stage4 is when features become non experimental, stage3 still has a chance of not making it (it's happened before)

@shakiba, according to Babel _arrow methods_, as I like to call them, are still in Stage 2 but it looks like they have now been promoted to Stage 3.

See:
https://babeljs.io/docs/plugins/transform-class-properties/
vs
https://github.com/tc39/proposal-class-fields

On a side note, the Stage 2 Babel plugin doesn't seem to be doing anything magical to arrow _methods_ - it simply transpiles them to arrow _functions_ defined within the constructor method (example).

Hope the discussion above helps! I'll close this but let me know if you have more questions.

Was this page helpful?
0 / 5 - 0 ratings