I
I
ivanDoligov2020-06-11 07:55:06
JavaScript
ivanDoligov, 2020-06-11 07:55:06

How to make optional chaining operator and esLint friends?

I can’t make friends with the optional chaining operator, that is, calling the function after checking, like this:
props.addFun?. ()

what I did:
- after reading, I installed the plugin '@babel/plugin-proposal-optional-chaining'

now, when using such an entry, the linter swears like this:

Expected an assignment or function call and instead saw an expression


The question is:
- is it correct that I connected the plugin?
- if this plugin was needed, then how to get rid of the error above

Answer the question

In order to leave comments, you need to log in

1 answer(s)
2
2CHEVSKII, 2020-06-11
@ivanDoligov

Your entry is incorrect. Should be:
props?.addFun()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question