I got this error when I used question mark after variable in react js
Module parse failed: Unexpected token (25:28) You may need an
appropriate loader to handle this file type.| console.log(cryptos); | useEffect(function () { > var filteredData = data?.data.coins.filter(function (item) { | return item.name.toLowerCase().includes(searchTerm); | });
Anyone faced this error before?
2
Answers
?. is an operator named as optional chain operator. It is new in es11. May be it’s not updated in react.js , that’s why you are getting error
Just check your NodeJS version with the following command.
As mentioned in the browser compatibility in the Optional chaining documentation, the NodeJS version should be at least 14.0.0.
If your NodeJS version is lower than it, you should upgrade it to use these latest features.