Skip to content
loading...

Optional chaining with React

Aki Rautio on December 09, 2019

13.1.2020 UPDATE: Babel 7.8.0 supports optional chaining out of the box Optional Chaining is one of the most requested features in Javascript (and... [Read Full]
markdown guide
 

Hey !

I don't really agree with the conclusion of your article.
Using this feature now is quite dangerous for you web performances. The way babel is transpiling the optional chaining is quite disgusting (ok, like every polyfill), but this one is not really necessary.

If you try to use it everywhere is your apps, you should notice that your bundle will swell quickly.

I wrote an article explaining why we should avoid this feature for now.

 

I would agree that performance wise it's not the best and the transpiled code looks ugly. But if this starts to cause performance issues, I would rather optimize the Babel transpiling than trying to fix it inside the application. Transpiling won't be eventually needed for most of browsers so this is a "temporary" issue.

 

I really like this. For my Gatsby project with VS Code, all I had to do was to click the TypeScript version number (which was 3.6.3) in the Status bar and choose Use Workspace Version 3.7.3. Done!

 

Oh so cool :) That's even easier way to get VSCode to work with this!

code of conduct - report abuse